Date: Wed, 3 Dec 2008 15:46:19 -0500
Reply-To: Ed Heaton <EdHeaton@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ed Heaton <EdHeaton@WESTAT.COM>
Subject: Re: avoid making macro just to use %if,
In-Reply-To: <98df8128-2fd3-4da6-8541-9535aa967f02@f13g2000yqj.googlegroups.com>
Content-Type: text/plain; charset="us-ascii"
How about this:
data second;
var='second';
run;
/*data _null_;*/
/* if %qsysfunc(exist(first)) then call symputx('set','first');*/
/* else call symputx('set','second');*/
/*run;*/
%let set = %sysFunc( ifC(
%sysFunc( exist(first) )
, first
, second
) ) ;
%put set=&set;
data output;
set &set ;
run;
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: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of GuyA
Sent: Wednesday, December 03, 2008 10:06 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: avoid making macro just to use %if,
I was thinking about this recently, with the difficulty I was having in making a conditional SET statement. The best thing I could come up with without a superfluous "macro wrapper" was the following:
/* Conditionally set dataset: */
data second;
var='second';
run;
data _null_;
if %qsysfunc(exist(first)) then call symputx('set','first');
else call symputx('set','second');
run;
%put set=&set;
data output;
set &set;
run;