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.
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
Thank you very much. That's very useful information. It helped me a lot.
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(¶m)=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)
Thank you very much for providing other better ways to check this. These suggestions are very very helpful.
Thank you for your valuable suggestion.
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!
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.
Ready to level-up your skills? Choose your own adventure.