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

I am facing below error while executing below macro.

can someone please help.

 

 

%macro test (stx = );

  %if &stx. ne %then %do;
  
    data test;
      test = "test quote";
    run;  
  
  %end;

%mend test;

%test (stx = %str(test ()-N)      );

abhinayingole_0-1641209912698.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Can you explain the larger picture? You have posted a number of questions about using macros and macro variables where macro variables have parentheses in them. It appears that you are constructing macros variables whose values have parentheses in the, and this seems inefficient and can cause lots of these types of problems, and I get the feeling there probably is a much easier way to handle this.

 

Your specific problem goes away with 

 

%if %superq(stx) ne %then %do;

  

--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

Can you explain the larger picture? You have posted a number of questions about using macros and macro variables where macro variables have parentheses in them. It appears that you are constructing macros variables whose values have parentheses in the, and this seems inefficient and can cause lots of these types of problems, and I get the feeling there probably is a much easier way to handle this.

 

Your specific problem goes away with 

 

%if %superq(stx) ne %then %do;

  

--
Paige Miller
abhinayingole
Obsidian | Level 7
Thanks for the solution.
It worked. 🙂

actually, in the dataset, the values of the variable has multiple possibility.
I am checking macro to work with every possibility.


Thanks you very much again for your help.
PaigeMiller
Diamond | Level 26

Modifying my answer to the following:

 

%if %bquote(&stx) ne %then %do;

I guess my feeling is that you use the lowest level of quoting needed, which would be %bquote rather than %superq; however not knowing the full extent of how this cod will be used, %superq may be needed for other values of &stx

--
Paige Miller

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 325 views
  • 0 likes
  • 2 in conversation