BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MadhuriAswale
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Why use %str() ? It makes them in different compile level  .

View solution in original post

5 REPLIES 5
Ksharp
Super User

Why use %str() ? It makes them in different compile level  .

MadhuriAswale
Calcite | Level 5

HI Xia , Thanks for the Answare .

could you please let me know why not to use %str

Ksharp
Super User

%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

Tom
Super User Tom
Super User

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;

Ksharp
Super User

OR Smiley Wink

proc sort data = comment_%unquote(&dataname) ;

  by subject aespid;

run;

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1204 views
  • 2 likes
  • 3 in conversation