楼主: 6203479170
1858 2

[原创博文] 宏变量的问题 [推广有奖]

  • 0关注
  • 0粉丝

硕士生

97%

还不是VIP/贵宾

-

威望
0
论坛币
90 个
通用积分
2.7600
学术水平
2 点
热心指数
7 点
信用等级
2 点
经验
292 点
帖子
125
精华
0
在线时间
219 小时
注册时间
2009-8-2
最后登录
2025-9-8

楼主
6203479170 发表于 2010-9-15 11:42:16 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
data _null_;
do i=1 to 10;
call symput("num||i",i);
end;
run;
我想把1-10的值赋值给NUM1到NUM10。请问上述代码错误的原因是什么,怎么解决呢?
二维码

扫码加我 拉你入群

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

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

关键词:symput null call Data NUM null

沙发
pobel 在职认证  发表于 2010-9-15 11:49:18
data _null_;
do i=1 to 10;
call symput("num"||strip(i),i);
end;
run;
和谐拯救危机

藤椅
bobguy 发表于 2010-9-17 09:23:47
pobel 发表于 2010-9-15 11:49
data _null_;
do i=1 to 10;
call symput("num"||strip(i),i);
end;
run;
It is a good practice to use call symputx rather ther call symput.

Here is the reasons.

CALL SYMPUTX is similar to CALL SYMPUT except that
  • 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.
  • 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.
  • 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.
  • CALL SYMPUTX enables you to specify the symbol table in which to store the macro variable, whereas CALL SYMPUT does not.
已有 1 人评分学术水平 收起 理由
soporaeternus + 1 学习了,十分感谢

总评分: 学术水平 + 1   查看全部评分

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

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