Date: Fri, 21 Dec 2001 10:23:38 -0600
Reply-To: "Krone, Ben --- Manager - Operations Systems --- GO"
<Ben.Krone@AF.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Krone, Ben --- Manager - Operations Systems --- GO"
<Ben.Krone@AF.COM>
Subject: Conditional running of a Macro
Content-Type: text/plain; charset="iso-8859-1"
Happy Holidays!
I am a macro novice and could use a little help on conditional running of a macro. Basically I want to check a parameter passed to the job and determine whether or not to further process based on the results of that check. Here is an example of the code I am running:
%macro main;
%step1;
%if &flag eq 'Y' %then %do;
%out1;
%end;
%else %do;
%out2;
%end;
%mend main;
%step1;
data _null_;
parm = sysparm();
call symput('parm',"'"||trim(parm)||"'");
run;
proc sql;
connect to db2 (ssid = dsn);
execute (set current degree = 'ANY') by db2;
create table flag as select * from connection to db2
(select flag
from db2table
where col1 = &parm
for fetch only);
disconnect from db2;
quit;
data _null_;
set flag;
call symput('flag',"'"||trim(flag)||"'");
run;
%mend step1;
%macro out1;
< further processing >
%mend out1;
%macro out2;
data _null_;
put 'Invalid parameter for this job';
run;
%mend out2;
%main;
When I run this, I get the following error:
WARNING: Apparent symbolic reference FLAG not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:
&flag eq 'Y'
ERROR: The macro MAIN will stop executing.
I am certain it has to do with the scope of the macro variable from the CALL SYMPUT, but I am not sure what an alternative would be.
Any help would be greatly appreciated.
Thanks
Ben
******************************************************************
This message contains information that is confidential
and proprietary to American Freightways Inc.
or its affiliates. It is intended only for the recipient
named and for the express purpose(s) described therein.
Any other use is prohibited.
*******************************************************************