Date: Tue, 12 May 2009 13:22:26 -0400
Reply-To: Croghan.Carry@EPAMAIL.EPA.GOV
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Carry Croghan <Croghan.Carry@EPAMAIL.EPA.GOV>
Subject: Re: Date macro variable issue
In-Reply-To: <200905121554.n4CAmwKM010847@malibu.cc.uga.edu>
Content-type: text/plain; charset=US-ASCII
A %let can not be conditionally run in a standard dataset. %let is a
global statement it is not a data step statement. Think of it like an
option statement. Each time SAS sees the code it will run it no matter
where it is.
If it needs to be conditionally set, you will need to run within a
macro.
Also you could you the %sysput statement instead to set your value.
Carry W. Croghan
Database Manager
EPA\ORD\NERL\HEASD
RTP, NC
From: Abc Unha <abcunha@YAHOO.COM>
To: SAS-L@LISTSERV.UGA.EDU
Date: 05/12/2009 11:55 AM
Subject: Re: Date macro variable issue
you are right, I used datepart function and it worked fine.
but there is still one issue.
I am not very much familier with let statement.
Somehow my tmp_date is alwasy last set to else or last stmt.
Why is my last stmt is setting tmp_date instead of first?
Thanks for the help
here is my code
Data _null_ ;
IF MONTH(today()) > 4 then do;
%let tmp_date = %Sysfunc(intnx(Year,"&sysdate9"d,-1,E)) ;
End;
Else do;
%let tmp_date = %Sysfunc(intnx(Year,"&sysdate9"d,-3,E)) ;
End;
Run;