- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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. */
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Are macro's always invoked without a ";" at the end?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I will keep an eye on these ";". Your suggestion has really made my day. Thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Calling @data_null__
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This macro is written by John King a.k.a @data_null__ .
I mentioned him here to let him notice this question .
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content