Reputation: 321
Originally, I have the code like this.
data newFile;
set File;
If Gender NE 'Female' then delete;
If Group NE 10 then delete;
If Age GT 30 then delete;
run;
It works just fine. But I want to be able to change those criteria from the top, so I add the macro variable. So far, I have this
&let macGender = 'Female';
&let macGroup = 10;
&let macAge = 30;
data newFile;
set File;
If Gender NE &macGender then delete;
If Group NE &macGroup then delete;
If Age GT &macAge then delete;
run;
It doesn't seem to work like the original's code. I even tried something like this
Upvotes: 1
Views: 81
Reputation: 1710
You want %let
rather than &let
.
%let
is the macro statement used to assign a value to a macro variable.
&let
is a reference to a macro variable which you (probably) have not created.
Upvotes: 6
Reputation: 201
put % signs instead of & infront of you let statement and get rid of your quotes around female in your macro declaration.
Put those quotes around the actual macro.
For example
%let macGender = Female;
if Gender NE "&macGender." then delete;
Upvotes: 1