楼主: sasa1881
1553 5

请教一段程序,哪里有错? [推广有奖]

  • 0关注
  • 1粉丝

已卖:297份资源

硕士生

36%

还不是VIP/贵宾

-

威望
0
论坛币
1410 个
通用积分
6.9349
学术水平
0 点
热心指数
2 点
信用等级
0 点
经验
1965 点
帖子
94
精华
0
在线时间
164 小时
注册时间
2008-7-24
最后登录
2014-5-5

楼主
sasa1881 发表于 2010-10-13 20:31:20 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
请问这段用宏实现的程序,统计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;
二维码

扫码加我 拉你入群

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

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

关键词:哪里有 SASHELP symput Global output 请教 程序

回帖推荐

crackman 发表于5楼  查看完整内容

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 ...

本帖被以下文库推荐

沙发
hopewell 发表于 2010-10-13 20:41:45
  1. %macro sss(dat,num);
  2.     %global mm;
  3.     data test;
  4.         set &dat;
  5.         if age eq &num then do;
  6.             sum+1;
  7.             output;
  8.         end;
  9.         call symputx('mm',sum);
  10.     run;
  11. %mend sss;

  12. %sss(sashelp.class, 13);
  13. %put NOTE:*** &mm ***;
复制代码
已有 2 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
crackman + 20 + 1 + 2 精彩帖子
soporaeternus + 1 + 1 + 1 我很赞同

总评分: 论坛币 + 20  学术水平 + 2  热心指数 + 3  信用等级 + 1   查看全部评分

观钓颇逾垂钓趣 种花何问看花谁

藤椅
sasa1881 发表于 2010-10-13 22:27:16
2# hopewell

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

板凳
sasa1881 发表于 2010-10-13 22:31:01
2# hopewell
还想请教call symput和callsymputx的区别,非常感谢

报纸
crackman 发表于 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.
已有 2 人评分学术水平 热心指数 信用等级 收起 理由
soporaeternus + 1 + 1 + 1 开班我抢头排.....占座......
hopewell + 1 + 1 + 1 crackman干脆开班授课吧

总评分: 学术水平 + 2  热心指数 + 2  信用等级 + 2   查看全部评分

地板
郑小知 发表于 2010-10-13 23:57:51
大牛们,小弟膜拜一下.

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-30 08:09