全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
17445 5
2010-01-21
当一个sas程序中出现这样的赋值语句:sourceSubset=%str(1=1),右边这个%str(1=1)作何解释呀?(注,sourceSubset为一个宏函数的默认参数)。

请高手赐教!!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2010-1-21 22:28:01
1# saslovime

%str(1=1)
Quote the string ‘1=1’ at macro compile time. Without quoting, the string may be resolved in an unexpected way at some cases, even I did not see what the quotation exactly functions here.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-1-22 09:20:46
jingju11 发表于 2010-1-21 22:28
1# saslovime

%str(1=1)
Quote the string ‘1=1’ at macro compile time. Without quoting, the string may be resolved in an unexpected way at some cases, even I did not see what the quotation exactly functions here.
You are right.

But it still seems to the %str here is redundant because (1=1) is a legitimate expression with no 'confusion'.


145  data _null_;
146    sourceSubset=1;
147    if sourceSubset=%str(1=1) then put '1';
148    else put '0';
149    run;

1
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


150
151    %macro t(d);
152       %let  sourceSubset=1;
153       %if &sourceSubset=%str(1=1) %then %put >>>1;
154       %else %put >>>0;
155    %mend;
156
157    %t(d);
>>>0
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-1-22 09:32:41
%str就是为了让一些类似等号的特殊符号可以解析。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-5-21 23:42:01
学习了
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-5-24 13:53:11
%str是屏蔽掉一些特殊的符号:如( ,),%等;上面的程序是返回一个逻辑表达式的值
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群