SAS中文论坛

标题: symget的问题,高手看看! [打印本页]

作者: shiyiming    时间: 2006-5-25 13:27
标题: symget的问题,高手看看!
%let cc=3;
%macro chgc(a);
data _null_;
call symput('cc',&a);
run;
%put &cc;
%mend chgc;

data _null;                              
do i=1 to 3;                           
call execute('%chgc('||i||')');      
t=2*symget('cc')+1;
output;
end;
run;

在执行了call execute之后,cc的改变了,但是为什么后面那句
symget('cc')得到的cc的值还是原来的值.
如果要使用新的cc的值该怎么处理,谢谢!
作者: shiyiming    时间: 2006-5-27 02:47
标题: RE:
the statement in %chgc() executes after the end of the data step's execution. Another word, it executes after Do...End statement in your case.   If you do not use %chgc, it can be resolved by using call symput() as below.
[code:f06ef]
data _null;
do i=1 to 3;
call symput('cc', i );
t=2*symget('cc')+1;
put t=;
end;
run;
[/code:f06ef]




欢迎光临 SAS中文论坛 (https://mysas.net/forum/) Powered by Discuz! X3.2