2015-04-03 65 views
0

在使用下劃線嘗試獲取宏變量以在宏定義內部解析時遇到問題。我想保持我在這裏的命名約定,但需要宏變量來解決這樣做。我錯過了什麼?宏變量無法用下劃線來解析

%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_. 

回答

4

%if dnr = 1 %then %let dnrname=est;

這就是問題所在。 dnr永不等於1。您錯過了&符號。