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

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 488 views
  • 0 likes
  • 2 in conversation