全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1554 5
2010-10-13
请问这段用宏实现的程序,统计sashelp.class年龄13岁的人并输出这些记录,将个数统计到sum宏变量中,哪里有问题,sum运行结果都是缺失值?
%macro sss(dat,num);
%global mm;
data test;
set &dat;
%if age eq &num %then %do;
  retain sum 0;
  sum=sum+1;
  output;
%end;
call symput('mm',sum);
run;
%mend sss;

%sss(sashelp.class, 13);
%put &mm;
二维码

扫码加我 拉你入群

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

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

全部回复
2010-10-13 20:41:45
复制代码
二维码

扫码加我 拉你入群

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

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

2010-10-13 22:27:16
2# hopewell

为什么不需要用%if 和%then %do呢,不是在宏里面的函数吗
二维码

扫码加我 拉你入群

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

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

2010-10-13 22:31:01
2# hopewell
还想请教call symput和callsymputx的区别,非常感谢
二维码

扫码加我 拉你入群

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

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

2010-10-13 22:42:37
The four benefits of CALL SYMPUTX are:
1.) CALL SYMPUTX does not write a note to the SAS log when the second argument is numeric. CALL SYMPUT, however, writes a note to the log stating that numeric values were converted to character values.
2.) CALL SYMPUTX uses a field width of up to 32 characters when it converts a numeric second argument to a character value. CALL SYMPUT uses a field width of up to 12 characters.
3.) CALL SYMPUTX left-justifies both arguments and trims trailing blanks.CALL SYMPUT does not left-justify the arguments, and trims trailing blanks from the first argument only. Leading blanks in the value of name cause an error.
4.) CALL SYMPUTX enables you to specify the symbol table in which to store the macro variable, whereas CALL SYMPUT does not. This is accomplished by an optional third argument to the SYMPUTX function.
二维码

扫码加我 拉你入群

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

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

2010-10-13 23:57:51
大牛们,小弟膜拜一下.
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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