由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - a question regarding sas programming
相关主题
One question about data step in sas问一个SAS里日期的问题,where is error?
SAS Macro question about %scan(&covariates,&h)请教2个sas base问题
问大家一个Macro的问题SAS advanced 真题中请教一题
请教两个SAS的问题请教SAS base 70题中的55题
where is error in SASsyntax errors
sas一问请教proc sql
怎样在data step跳过格式不对的data record?什么时候r里兴用=赋值的
包子请教,时间格式问题请教:Use R to do integration
相关话题的讨论汇总
话题: mx话题: let话题: put话题: m1话题: note
进入Statistics版参与讨论
1 (共1页)
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;

1 (共1页)
进入Statistics版参与讨论
相关主题
请教:Use R to do integrationwhere is error in SAS
有什么sas log的viewer吗sas一问
SAS call symput question怎样在data step跳过格式不对的data record?
我的SAS CODE 错那儿了?包子请教,时间格式问题
One question about data step in sas问一个SAS里日期的问题,where is error?
SAS Macro question about %scan(&covariates,&h)请教2个sas base问题
问大家一个Macro的问题SAS advanced 真题中请教一题
请教两个SAS的问题请教SAS base 70题中的55题
相关话题的讨论汇总
话题: mx话题: let话题: put话题: m1话题: note