EA 发帖数: 3965 | 1 I have a code like following
%let m1=99;
%let m2=55;
data _null_;
do x=1 to 2;
%let y=x;
put &y;
mx=&&m&y;
put mx;
end;
run;
and got the folloing log
1 %let m1=99;
2 %let m2=55;
3
4 data _null_;
5 do x=1 to 2;
6 %let y=x;
7 put &y;
8 mx=&&m&y;
NOTE: Line generated by the macro variable "Y".
1 &mx
-
22
WARNING: Apparent symbolic reference MX not resolved.
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted
string,
a numeric constant, a datetime constant, a missing value,
INPUT, PUT.
9 put mx;
10 end;
11 run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
I want the code can return me the values of the two macro variables &m1 and
&m2. How can I fix it?
If I only run this part, the results are OK, but why it returned me &mx
instead of
&m1 and &m2 after I added mx=&&m&y?
data _null_;
do x=1 to 2;
%let y=x;
put &y;
end;
run; | m*****a 发帖数: 658 | 2 I guess &y was thought as text in &&m&y.
you can do like this
%let m1=99;
%let m2=55;
%macro try;
%do y=1 %to 2;
%put &&m&y;
%end;
%mend;
%try; | s******r 发帖数: 1524 | 3 data _null_;
%do x=1 %to 2;
%let y=&x;
%put &y;
mx=&&m&y;
put mx;
%end;
run;
【在 EA 的大作中提到】 : I have a code like following : %let m1=99; : %let m2=55; : data _null_; : do x=1 to 2; : %let y=x; : put &y; : mx=&&m&y; : put mx; : end;
| o****o 发帖数: 8077 | 4 这个涉及macro facility跟data step界面之间的时序问题
参见SAS的手册,有专门讲解
【在 EA 的大作中提到】 : I have a code like following : %let m1=99; : %let m2=55; : data _null_; : do x=1 to 2; : %let y=x; : put &y; : mx=&&m&y; : put mx; : end;
|
|