From: Jim Groeneveld on
Hi Yom,

Your code is all right, but the contents of &macrolist are being resolved
at this time and made active, leading to an illegal %IF statement.
You should let the variable resolve one only and not be processed further
by quoting. See also my example code to you from yesterday, then I used %
QSCAN, but if you only want to see if there is anything in the variable
you may use %STR here:
%if %STR(&macrolist.) ne %then %do;
And for reasons of clarity I always surround my conditional parts with
parentheses, like required with WHILE and UNTIL:
%if (%STR(&macrolist.) ne) %then %do;

Regards - Jim.
--
Jim Groeneveld, Netherlands
Statistician, SAS consultant
home.hccnet.nl/jim.groeneveld

My computer remains home while I will attend PhUSE 2006 in Dublin.

On Tue, 5 Sep 2006 15:50:25 +0200, yom <yomsas(a)GMAIL.COM> wrote:

>Dear All,
>
>I have this statement :
>macrolist=%NRSTR(%mymacro1
>(file=&file1,varlist=&varlist1,outfolder=&outfolder1));
> I would like to test if macrolist is empty or not.
>If I use
>%if &macrolist. ne %then %do;
>.....
>%end;
>I get this error message :
>ERROR: Required operator not found in expression: &macrolist. ne
>Please do you know what I have to add ?
>
>Thank you very much in advance !
>
>yom
From: toby dunn on
Yom ,

First off your macro variable will never be empty the way you have it coded
up:

%mymacro1(file=&file1,varlist=&varlist1,outfolder=&outfolder1)

Is always the results. You should learn macros before you jump into using
macro qouting. %Nrstr qoutes the value at compile time not execution time.


%Macro Test( AAA = ) ;

%If ( &AAA = ) %Then %Do ;
%put Empty!!! ;
%End ;
%Else %do ;
%Put Not Empty!!! ;
%End ;
%Mend ;

%Test( AAA = )
%Test( AAA = ABCD )



Toby Dunn

When everything is coming at you all at once, your in the wrong lane.

A truly happy person is someone who can smile and enjoy the scenery on a
detour.





From: yom <yomsas(a)GMAIL.COM>
Reply-To: yom <yomsas(a)GMAIL.COM>
To: SAS-L(a)LISTSERV.UGA.EDU
Subject: Check if macro parameter is empty
Date: Tue, 5 Sep 2006 15:50:25 +0200

Dear All,

I have this statement :
macrolist=%NRSTR(%mymacro1
(file=&file1,varlist=&varlist1,outfolder=&outfolder1));
I would like to test if macrolist is empty or not.
If I use
%if &macrolist. ne %then %do;
.......
%end;
I get this error message :
ERROR: Required operator not found in expression: &macrolist. ne
Please do you know what I have to add ?

Thank you very much in advance !

yom
From: "Terjeson, Mark" on
Hi yom,





* your original version ;
%let
macrolist=%NRSTR(%mymacro1(file=&file1,varlist=&varlist1,outfolder=&outf
older1));
%macro MyMacro;
%if &macrolist. ne %then
%do;
%put macrolist is >&macrolist<;
%end;
%mend;
%MyMacro;




* *** A TIMING SUBTLETY ***;
* you can see by the two samples below that the %NRSTR gets used ;
* upon resolution. i.e. not during the %LET assignment, but in ;
* the %PUT when the &macrolist gets resolved! You cannot tell ;
* by the %LET and %PUT by themselves, but when we compare it to ;
* the following macro, and which error messages you get!!! ;
%let
macrolist=%NRSTR(%mymacro1(file=&file1,varlist=&varlist1,outfolder=&outf
older1));
%put macrolist is >&macrolist<; * as seen here ;
* at this point it you can see that the %NRSTR is gobbled up, ;
* but you cannot tell if it is at assignment-or-resolution-time. ;






* if at assignment-time, text-substitution would yield ;
%macro MyMacro;
%if %mymacro1(file=&file1,varlist=&varlist1,outfolder=&outfolder1)
ne %then
%do;
%put macrolist is >&macrolist<;
%end;
%mend;
%MyMacro;
* error messaging not the same as your original message ;



* if at resolution-time, text-substitution would yield ;
%macro MyMacro;
%if
%NRSTR(%mymacro1(file=&file1,varlist=&varlist1,outfolder=&outfolder1))
ne %then
%do;
%put macrolist is >&macrolist<;
%end;
%mend;
%MyMacro;
* error messaging is the same as your original message, ;
* except for the obvious portrayal of the difference in ;
* the text being shown back to you. ;







* since all macro variables are string, merely informing ;
* the compiler that that is what you want to evaluate is ;
* going to eliminate any error messages. ;
* you can use several functions to effectively wrap the ;
* string as a whole and not have it parsed out... ;
%let
macrolist=%NRSTR(%mymacro1(file=&file1,varlist=&varlist1,outfolder=&outf
older1));
%macro MyMacro;
%if %NRSTR(&macrolist.) ne %then
%do;
%put macrolist is >&macrolist<;
%end;
%mend;
%MyMacro;


-or-


%let
macrolist=%NRSTR(%mymacro1(file=&file1,varlist=&varlist1,outfolder=&outf
older1));
%macro MyMacro;
%if %quote(&macrolist.) ne %then
%do;
%put macrolist is >&macrolist<;
%end;
%mend;
%MyMacro;



Hope this is helpful,

Mark Terjeson




-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On Behalf Of yom
Sent: Tuesday, September 05, 2006 6:50 AM
To: SAS-L(a)LISTSERV.UGA.EDU
Subject: Check if macro parameter is empty

Dear All,

I have this statement :
macrolist=%NRSTR(%mymacro1
(file=&file1,varlist=&varlist1,outfolder=&outfolder1));
I would like to test if macrolist is empty or not.
If I use
%if &macrolist. ne %then %do;
......
%end;
I get this error message :
ERROR: Required operator not found in expression: &macrolist. ne Please
do you know what I have to add ?

Thank you very much in advance !

yom
From: yom on
Thank you very much for your help !
But if I use %str I get the same error.

Here is the full code :


%macro example;

%macro test(macrolist=);
%if %str(&macrolist.) ne %then %do;
%Put Not Empty!!! ;
%End ;
%Else %do ;
%Put Empty!!! ;
%End ;
%mend;

%test(macrolist=%NRSTR(%val(file=aaa)));

%mend;

%example;






2006/9/5, toby dunn <tobydunn(a)hotmail.com>:
>
> Yom ,
>
> First off your macro variable will never be empty the way you have it
> coded
> up:
>
> %mymacro1(file=&file1,varlist=&varlist1,outfolder=&outfolder1)
>
> Is always the results. You should learn macros before you jump into using
> macro qouting. %Nrstr qoutes the value at compile time not execution time.
>
>
> %Macro Test( AAA = ) ;
>
> %If ( &AAA = ) %Then %Do ;
> %put Empty!!! ;
> %End ;
> %Else %do ;
> %Put Not Empty!!! ;
> %End ;
> %Mend ;
>
> %Test( AAA = )
> %Test( AAA = ABCD )
>
>
>
> Toby Dunn
>
> When everything is coming at you all at once, your in the wrong lane.
>
> A truly happy person is someone who can smile and enjoy the scenery on a
> detour.
>
>
>
>
>
> From: yom <yomsas(a)GMAIL.COM>
> Reply-To: yom <yomsas(a)GMAIL.COM>
> To: SAS-L(a)LISTSERV.UGA.EDU
> Subject: Check if macro parameter is empty
> Date: Tue, 5 Sep 2006 15:50:25 +0200
>
> Dear All,
>
> I have this statement :
> macrolist=%NRSTR(%mymacro1
> (file=&file1,varlist=&varlist1,outfolder=&outfolder1));
> I would like to test if macrolist is empty or not.
> If I use
> %if &macrolist. ne %then %do;
> ......
> %end;
> I get this error message :
> ERROR: Required operator not found in expression: &macrolist. ne
> Please do you know what I have to add ?
>
> Thank you very much in advance !
>
> yom
>
>
>
From: "Dorfman, Paul" on
Yom,

Without getting into the technicalities of why you are getting the
message (you can find more than you wish to chew on that in sas-l
archives), use the bulletproof

If %length (&macrolist) > 0 %then...

And the period indicating the end of a macro variable is only necessary
when it is necessary. Where it is not necessary, it may result in
confusion without adding any extra robustness (which is perhaps what was
intended) or functionality. All of which is only my opinion, of
course...

Kind regards
------------
Paul Dorfman
Jax, FL
------------

+-----Original Message-----
+From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On
+Behalf Of yom
+Sent: Tuesday, September 05, 2006 9:50 AM
+To: SAS-L(a)LISTSERV.UGA.EDU
+Subject: Check if macro parameter is empty
+
+
+Dear All,
+
+I have this statement :
+macrolist=%NRSTR(%mymacro1
+(file=&file1,varlist=&varlist1,outfolder=&outfolder1));
+ I would like to test if macrolist is empty or not.
+If I use
+%if &macrolist. ne %then %do;
+.....
+%end;
+I get this error message :
+ERROR: Required operator not found in expression: &macrolist. ne
+Please do you know what I have to add ?
+
+Thank you very much in advance !
+
+yom
+
+


------------------------------------------------------------------------------
Notice: This e-mail message, together with any attachments, contains
information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station,
New Jersey, USA 08889), and/or its affiliates (which may be known
outside the United States as Merck Frosst, Merck Sharp & Dohme or MSD
and in Japan, as Banyu - direct contact information for affiliates is
available at http://www.merck.com/contact/contacts.html) that may be
confidential, proprietary copyrighted and/or legally privileged. It is
intended solely for the use of the individual or entity named on this
message. If you are not the intended recipient, and have received this
message in error, please notify us immediately by reply e-mail and then
delete it from your system.

------------------------------------------------------------------------------