yzzhang 发表于 2009-12-1 13:43 
现在建立两个宏变量
%let a1=100; %let a2=200;
现在想根据变量n取不同值分别引用两个宏变量,也即
当n=1时,引用a1; 当n=2时,引用a2;
想写成call symput('n',n); 然后在&&a&n来引用发现根本不行,还望高手执教;
When you say 引用, I think you want to refer them in your program conditional on the other variable n. If this is the case, you can use symget with a data step.
Here is an example,
%let a1=100; %let a2=200;
data _null_;
do i= 1 to 10;
n=1 + ( ranuni(56)<0.5 );
mv=cats('a',n);
x=symget(mv);
put i= @10 n= mv x=;
end;
run;