BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Moksha
Pyrite | Level 9

Hi All,

        I have a very general question. Suppose if a macro variable resolves to blank then how to check that it resolved blank. 

 

For example, if I have macro variable say varname created using into clause of proc sql and this variable contains two values var1 and var2.  When I check if each of these var1 and var2 in a dataset that is containing only var1 , then in the log I get 

 

SYMBOLGEN:  Macro variable VAR2 resolves to

 

Thanks

 

Here, how to check if VAR2 resolved to nothing that is blank? I want to check this because based on whether it resolved or not I have to do next steps.

 

1 ACCEPTED SOLUTION
7 REPLIES 7
Moksha
Pyrite | Level 9

I have used the following and it worked:

%if %length(&varname) ne 0 %then %do;
    statements.....
%end;

Please, let me know if there are any other better ways to do this instead of using %length().

 

Thanks

Moksha
Pyrite | Level 9

Thank you very much. That's very useful information. It helped me a lot.

Tom
Super User Tom
Super User

Define BLANK.

 

If you want to test if it is empty then length of zero is the best way.  That will let you tell the difference between an empty string and one that only contains blanks.

 

%length(&param)=0

 

If you want to test if it only contains spaces then the paper by Chung and King linked above is what you want to check out.  Their recommendation is

 

%sysevalf(%superq(param)=,boolean)

Moksha
Pyrite | Level 9

Thank you very much for providing other better ways to check this. These suggestions are very very helpful.

Moksha
Pyrite | Level 9

Thank you for your valuable suggestion.

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
  • 7 replies
  • 1854 views
  • 1 like
  • 4 in conversation