[英]Struggling with passing macro value in SAS
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
而不是&let
。
%let
is the macro statement used to assign a value to a macro variable. %let
是用于将值分配给宏变量的宏语句。
&let
is a reference to a macro variable which you (probably) have not created. &let
是对您(可能)尚未创建的宏变量的引用。
put % signs instead of & infront of you let statement and get rid of your quotes around female in your macro declaration. 在您的宏声明中用%号代替&在您的前面让let声明并消除女性的引号。
Put those quotes around the actual macro. 将这些引号放在实际的宏周围。
For example 例如
%let macGender = Female; %let macGender =女性;
if Gender NE "&macGender." 如果是Gender NE“&macGender”。 then delete;
然后删除;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.