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

Hi Everyone,

 

   I've been spending a lot of time on this macro routine and could not figure out what is going on.  In this link, Chung and King presented a macro, isBlank, to test if a macro's argument is blank. In this discussion, Ballardw illustrated a usage of isBlank. However, when I used isBlank in my test macro below, the IF condition is never true. Somehow the 1 returned by %isBlank looks like a 1 but is not really a 1. Would someone help to demystify this please. Thank you very much.

 

-Chin

 

%macro isBlank(param);
  %sysevalf(%superq(param)=,boolean);
%mend isBlank;

 

%put %isBlank(); /* Returns 1. */
%put %isBlank(a); /* Returns 0. */

 

%macro test(arg);
    %if %isBlank(&arg) = 1 %then %put Blank;   /* This IF is never true.  Is %isBlank(&arg) returning a numerical 1? */
    %else %put Notblank; run;
%mend;

 

%test();     /* Returns: Notblank  */
%test(a);   /* Returns: Notblank ALSO. */

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

I can't test this right now, but to my eyes, your macro definition is incorrect.  You have an extra semicolon on this line:

 

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

 

"Extra" here means that you have one, but there shouldn't be any.

View solution in original post

12 REPLIES 12
PaigeMiller
Diamond | Level 26

The %isblank macro works on macro variables. If you feed it text or a null argument, I have no idea what it will do, but it wasn't designed for that.

 

So

 

%let a=XXX;

%put %isblank(&a); /* Should return a 1 */

 

%let a=;

%put %isblank(&a); /* Should return a 0 */

--
Paige Miller
chinli72
Obsidian | Level 7

PaigeMiller, Thank you for your reply. While I was trying out your suggestion, Astounding replied another solution, which I quickly tested and confirmed that is where my problem is. Thank you for your help.  -Chin

 

PaigeMiller
Diamond | Level 26

@PaigeMiller wrote:

The %isblank macro works on macro variables. If you feed it text or a null argument, I have no idea what it will do, but it wasn't designed for that.

 

So

 

%let a=XXX;

%put %isblank(&a); /* Should return a 1 */

 

%let a=;

%put %isblank(&a); /* Should return a 0 */


Correcting my reply

 

%let a=XXX;
%put %isblank(&a); /* Should return a 0 */

%let a=;
%put %isblank(&a); /* Should return a 1 */

 

--
Paige Miller
Astounding
PROC Star

I can't test this right now, but to my eyes, your macro definition is incorrect.  You have an extra semicolon on this line:

 

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

 

"Extra" here means that you have one, but there shouldn't be any.

chinli72
Obsidian | Level 7
Astounding, You are absolutely correct. By removing the ";" in isBlank macro, the code worked. Truly astounded. Thank you very much.
chinli72
Obsidian | Level 7

Are macro's always invoked without a ";" at the end?

Astounding
PROC Star

No, ";" is never needed at the end of a macro invocation.  As a result, if you add one, it adds ";" to the program at that point  Much of the time an extra semicolon in the middle of a program doesn't hurt anything.  But in this case, it would.

chinli72
Obsidian | Level 7

I will keep an eye on these ";". Your suggestion has really made my day. Thanks again.

chinli72
Obsidian | Level 7

Hi Ksharp,

 

    Are you suggesting that on the 2nd line, the added ";" 

 

       %macro isBlank(param) /store source;
           %sysevalf(%superq(param)=,boolean);
       %mend isBlank;

 

has the effect as 

 

       %macro isBlank(param) /store source;
           @Data_null_
       %mend isBlank;

 

calling @data_null__?  

 

Thank you.

Ksharp
Super User

This macro is written by John King a.k.a  @data_null__ .

I mentioned him here to let him notice this question .

chinli72
Obsidian | Level 7
Got it. Thank you.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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