全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1998 6
2010-01-22
sashelp.prdsale totalobs 明明大于10, 为什么RC最后的结果是 LOW...?  谢谢了~

options symbolgen;
%let rc=Begin;
%macro test;
data out;
set sashelp.prdsale nobs=totalobs;
if totalobs > 10 then do;
%let rc=high;
end;
else do;
%let rc=low;
end;
run;
%mend;
%let rc= Before Execution;
%test
%put answer: &rc;




二维码

扫码加我 拉你入群

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

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

全部回复
2010-1-22 19:54:26
SAS仅依次解析了
复制代码
复制代码
各一遍
故&rc 值是low

这里可能使用call symput会好些

%语句 仅仅是文本替换而已
二维码

扫码加我 拉你入群

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

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

2010-1-23 00:27:21
哦~谢谢~ 我苦思冥想了很久:S
二维码

扫码加我 拉你入群

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

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

2010-1-23 03:13:00
3# oxygenmz

编译次序造成的;
二维码

扫码加我 拉你入群

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

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

2010-1-23 08:00:41
%let rc=Begin;
%macro test;
data out;
set sashelp.prdsale nobs=totalobs;
new=totalobs;
%if totalobs >10 %then %do;
%let rc=high;
%end;
%else %do;
%let rc=low;
%end;
run;
%mend;
%let rc= Before Execution;
%test
%put answer: &rc;


这样就变high了













1# oxygenmz
二维码

扫码加我 拉你入群

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

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

2010-1-23 10:32:32
oxygenmz 发表于 2010-1-22 14:43
sashelp.prdsale totalobs 明明大于10, 为什么RC最后的结果是 LOW...?  谢谢了~

options symbolgen;
%let rc=Begin;
%macro test;
data out;
set sashelp.prdsale nobs=totalobs;
if totalobs > 10 then do;
%let rc=high;
end;
else do;
%let rc=low;
end;
run;
%mend;
%let rc= Before Execution;
%test
%put answer: &rc;




Others already pointed out where the problem is.

Here is a simpler version of you codes.

%macro nobs(dsn=);
    data _null_;
      if 0 then set &dsn nobs=nobs;   ***note nobs is available at compiling time. Not needed to open it and read it;
      if nobs >10 then call symputx('rc','High');
      else  call symputx('rc','Low');
    run;
    %put rc=&rc;
%mend;

%nobs(dsn=sashelp.class)
data t1;
x=1;
run;
%nobs(dsn=t1)
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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