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
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.
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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.