Hi Forum,
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;
run;
%mend outer_reconcil;
%outer_reconcil(dataname = %str(Event_not_rec));
still getting
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
for printing.
NOTE: Line generated by the macro variable "DATANAME".
1 comment_Event_not_rec
-------------
22
-------------
202
ERROR: File WORK.COMMENT_.DATA does not exist.
MPRINT(OUTER_RECONCIL): proc sort data = comment_Event_not_rec by subject aespid;
MPRINT(OUTER_RECONCIL): run;
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,
WORKNO.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
NOTE: The SAS System stopped
Why use %str() ? It makes them in different compile level .
Why use %str() ? It makes them in different compile level .
HI Xia , Thanks for the Answare .
could you please let me know why not to use %str
%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 .
Xia Keshan
Message was edited by: xia keshan
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;
run;
OR
proc sort data = comment_%unquote(&dataname) ;
by subject aespid;
run;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.