Date: Tue, 8 Apr 2008 08:50:27 -0400
Reply-To: Ed Heaton <EdHeaton@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ed Heaton <EdHeaton@WESTAT.COM>
Subject: Re: IsBlank() in macro. Was: Re: Macro variable resolves to -
question
In-Reply-To: <7367b4e20804071340s291d498et24aa6ddcc093903e@mail.gmail.com>
Content-Type: text/plain; charset="us-ascii"
1 %macro isBlank(arg);
2 %*;%eval("%qsysfunc(trimn(%superq(arg)))" = "")
3 %mend isBlank;
4 %let x=(;
5 %let l = %isBlank(&x) ;
6 %put %nrStr(&l)=&l ;
ERROR: Open code statement recursion detected.
Here's my original question with modifications. Can you tell me where
this %isBlank() macro would work when the following would not?
%macro isBlank(arg) ;
%eval( %length(&arg) gt 0 )
%mEnd isBlank ;
Ed
Edward Heaton, Senior Systems Analyst,
Westat (An Employee-Owned Research Corporation),
1650 Research Boulevard, TB-286, Rockville, MD 20850-3195
Voice: (301) 610-4818 Fax: (301) 294-2085
mailto:EdHeaton@Westat.com http://www.Westat.com
-----Original Message-----
From: data _null_, [mailto:datanull@gmail.com]
Sent: Monday, April 07, 2008 4:41 PM
To: Ed Heaton
Cc: Chang Chung; SAS-L@listserv.uga.edu
Subject: Re: IsBlank() in macro. Was: Re: Macro variable resolves to -
question
3222 %let x=(;
3223 %let l=%length(&x);
NOTE: One or more missing close parentheses have been supplied for the
%LENGTH function.
I think you still need to quote something.
On Mon, Apr 7, 2008 at 3:28 PM, Ed Heaton <EdHeaton@westat.com> wrote:
> Chang;
>
> Hmmm. Can you tell me when your macro would return something
> different than the following?
>
> %macro isBlank(arg) ;
> %eval( %length(&arg) gt 0 )
> %mEnd isBlank ;
>
> For that matter, since 0 is false and any other positive integer in
> true (in macro), how about just...
>
> %macro isBlank(arg) ;
> %length(&arg)
> %mEnd isBlank ;
>
> Hmmm. Why do we even need a macro? Can we just use %length() in our
> code?
>
> Ed
>
> Edward Heaton, Senior Systems Analyst,
> Westat (An Employee-Owned Research Corporation),
> 1650 Research Boulevard, TB-286, Rockville, MD 20850-3195
> Voice: (301) 610-4818 Fax: (301) 294-2085
> mailto:EdHeaton@Westat.com http://www.Westat.com
>
>
>
>
>
> -----Original Message-----
> From: owner-sas-l@listserv.uga.edu
> [mailto:owner-sas-l@listserv.uga.edu]
> On Behalf Of Chang Chung
> Sent: Monday, April 07, 2008 4:03 PM
> To: SAS-L@LISTSERV.UGA.EDU; Data _Null_;
> Subject: IsBlank() in macro. Was: Re: Macro variable resolves to -
> question
>
>
> hi,
>
> in order to check if something is "blank" or not, maybe all we need is
> this
> one-liner:
>
> %*-- returns 1 if arg is blank(s). 0 otherwise--*;
> %macro isBlank(arg); %*;%eval("%qsysfunc(trimn(%superq(arg)))" = "")
> %mend isBlank;
>
> so that we can use it like:
> %*-- check --*;
> %macro test(parm);
> %local not;
> %let not=not%str( );
> %if %isBlank(%superq(parm)) %then %let not=;
> %put NOTE: **%superq(parm)** is ¬.blank.;
> %mend test;
> %test(abcde)
> %test(%str( ))
> %*-- on log
> NOTE: **abcde** is not blank.
> NOTE: ** ** is blank.
> */
>
> any comments will be greatly appreciated. Thanks.
> cheers,
> chang
>
|