在使用下划线时尝试获取宏变量以解析宏定义时出现问题。我想保留我在这里的命名约定,但需要宏变量来解决这个问题。我错过了什么?
%macro mymacro(dd=,mm=,yy=,dnr=,dma=);
.
.
.
%if dnr = 1 %then %let dnrname=est;
%if dnr = 2 %then %let dnrname=cen;
%if dnr = 3 %then %let dnrname=mtec;
%if dnr = 4 %then %let dnrname=pac;
%if dnr = 5 %then %let dnrname=mtwp;
data setoff_&dnrname._&dma._&mm.&dd.&yy.;
set restart_no retimed one_min_durations;
run;
.
.
.
%mend mymacro;
错误如下:
NOTE: Line generated by the invoked macro "SETOFF".
89 data setoff_&dnrname._&dma._&mm.&dd.&yy.; set restart_no retimed one_min_durations;
-
22
200
89 ! run; proc sort data = setoff_&dnrname._&dma._&mm.&dd.&yy.; by &dims_list. sid; run;
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, /, ;,
_DATA_, _LAST_, _NULL_.
答案 0 :(得分:4)
%if dnr = 1 %then %let dnrname=est;
这就是问题所在。 dnr
永远不等于1
。你错过了&符号。