12-22-2014 06:07 AM
Could you please help me to figure out what is the wrong with my macro code below , i have created macro variable at the end .
%macro outer_reconcil(dataname =%str() );
proc sort data = comment_&dataname;
by subject aespid;
%outer_reconcil(dataname = %str(Event_not_rec));
15355 %outer_reconcil(dataname = %nrbquote(Event_not_rec));
MLOGIC(OUTER_RECONCIL): Beginning execution.
MLOGIC(OUTER_RECONCIL): Parameter DATANAME has value Event_not_rec
SYMBOLGEN: Macro variable DATANAME resolves to Event_not_rec
SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted
NOTE: Line generated by the macro variable "DATANAME".
ERROR: File WORK.COMMENT_.DATA does not exist.
MPRINT(OUTER_RECONCIL): proc sort data = comment_Event_not_rec by subject aespid;
ERROR 22-322: Syntax error, expecting one of the following: ;, (, ASCII, BUFFNO, DANISH, DATA,
DATECOPY, DETAILS, DIAG, DUPOUT, EBCDIC, EQUALS, FINNISH, FORCE, IN, ISA, L, LEAVE,
LIST, MESSAGE, MSG, NATIONAL, NODUP, NODUPKEY, NODUPKEYS, NODUPLICATE, NODUPLICATES,
NODUPREC, NODUPRECS, NODUPS, NOEQUALS, NORWEGIAN, NOTHREADS, NOUNIKEY, NOUNIKEYS,
NOUNIQUEKEY, NOUNIQUEKEYS, NOUNIQUEREC, NOUNIQUERECS, NOUNIREC, NOUNIRECS, OSA, OUT,
OVERWRITE, PAGESIZE, PRESORTED, PSIZE, REVERSE, SIZE, SORTSEQ, SORTSIZE, SORTWKNO,
SWEDISH, T, TAGSORT, TECH, TECHNIQUE, TESTHSI, THREADS, UNIOUT, UNIQUEOUT, WKNO,
ERROR 202-322: The option or parameter is not recognized and will be ignored.
NOTE: The SAS System stopped
12-22-2014 07:07 AM
%str(Event_not_rec) is in a compile stage . comment_ is in another compile stage . when you put them together comment_%str(Event_not_rec) , SAS would compile them in the different stage . That is reason why you got ERROR .
To clarify something more . %str() %nrstr() %superq() ......... they are all macro variable mask function , they will add mask character around macro variable . For this example , you can take it as \bEvent_not_rec\b , \b is the mask character , therefore the real code generated in compile engine is comment_\bEvent_not_rec\b , so you get the ERROR message . if you don't put %str() around it , it will generate code comment_Event_not_rec , that is right code we need .
Message was edited by: xia keshan
12-22-2014 10:47 AM
Because you quoted the macro string in the call it is confusing the parser. It sees two tokens instead of one.
Your macro can adjust for this by adding an %UNQUOTE().
proc sort data = %unquote(comment_&dataname) ;
by subject aespid;
Need further help from the community? Please ask a new question.