Date: Fri, 24 Nov 2006 14:27:48 -0500
Reply-To: sbarry@sbbworks.com
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Scott Barry <sbarry@SBBWORKS.COM>
Organization: SBBWorks, Inc.
Subject: Re: require help in the program to find holiday
Content-Type: text/plain; charset="us-ascii"
I use a combination of SAS-formatted date values (format: ddmmm, by using SAS format date5. with a
PUT function call) which are holidays every year, as well as other date/year-specific literal values
(trailing "D" denotes a date value) in a SAS DATA step IF THEN ELSE expression, as shown below
(reference U. S. holidays for illustration):
%MACRO TEST_HOLIDAY(date_var=MYDATE,holiday_var=HOLIDAY);
%* data step macro logic to assign holiday indicator Y/N ;
IF PUT(&date_var,DATE5.) IN ('01JAN','04JUL','25DEC') OR
&date_var IN (
'30MAY2005'D
'04JUL2005'D
'05SEP2005'D
'24NOV2005'D
'24DEC2005'D
'02JAN2006'D
'29MAY2006'D
'04SEP2006'D
'23NOV2006'D
'02JAN2007'D
'28MAY2007'D
'03SEP2007'D
'22NOV2007'D
) THEN &holiday_var='Y';
ELSE &holiday_var='N';
%MEND TEST_HOLIDAY;
* DATA STEP CODE TO TEST HOLIDAY INDICATORY ASSIGNMENT. ;
DATA _NULL_;
FORMAT MY_DATE DATE9.;
* DO LOOP FOR DATE VALUES. ;
DO MY_DATE=MDY(1,1,YEAR(TODAY())) TO MDY(1,1,YEAR(TODAY())+1);
%TEST_HOLIDAY(DATE_VAR=MY_DATE);
PUT _ALL_;
END;
RUN;
Sincerely,
Scott Barry
SBBWorks, Inc.
gurtej wrote:
> Dear All,
> I am stuck at one problem
> I am working on a data where i get a start date and from start date i
> have to calulate finish date
> the conditions are as follows
> start date+1=finish date
> cond
> if start date+1 = holiday then
> start date+2=finish date
> but if start date+2= holiday then
> start date+3=finish date
> the no wil go on increasing till we get a date when there is no
> holiday.
> so the final ideal equation is
> start date+no of holidays+1=finish date
> e.g
> start date = 14th aug
> holiday=15ht aug
> so finish date will be
> start date + no of holiday (ie 1) ie 16th aug
> but if 16th aug is also holiday then finish date will be calculated as
> start date+no of holiday(i.e 2 for 15th and 16th aug) and will come as
> 17th aug.
> if you can please help me out in this matter..