LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 2012, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 5 Apr 2012 20:36:15 +0530
Reply-To:     Vasanth S <vasanthz@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Vasanth S <vasanthz@GMAIL.COM>
Subject:      Re: SAS : Help in 'dating'
In-Reply-To:  <1333637308.53938.YahooMailNeo@web88609.mail.bf1.yahoo.com>
Content-Type: text/plain; charset=ISO-8859-1

Hi, As mentioned the HOLIDAY function does not consider if a holiday falls on Saturday or Sunday. So modified Michael's code(earlier in this thread) to account for this scenario.

Here is the code, */* If any of the holidays( New years, Independence Day, Christmas) fall on Saturday, then the previous Friday is declared as holiday. If any of the holidays( New years, Independence Day, Christmas) fall on Sunday, then the following Monday is declared as holiday. */

DATA HOLIDAYS; LENGTH Holiday_Name $20; FORMAT MDY_SAS DATE9.; LABEL MDY_SAS = 'HOLIDAY ON';

DO YEAR = 2009 TO 2012; /* INTERVAL OF YEARS */ Holiday_name = 'NEW YEAR'; MDY_sas = mdy(1,1,Year); /* JANUARY 1ST */ Wk_Day = weekday(MDY_sas); if Wk_Day = 7 then MDY_sas = MDY_sas - 1; else if wk_day = 1 then MDY_sas = MDY_sas + 1; output;

Holiday_name = 'MEMORIAL DAY'; MDY_sas = intnx('week.2',mdy(5,31,year),0); /* LAST MONDAY MAY */ output;

Holiday_name = 'INDEPENDENCE DAY'; /* JULY 4TH */ MDY_sas = mdy(7,4,Year); Wk_Day = weekday(MDY_sas); if Wk_Day = 7 then MDY_sas = MDY_sas - 1; else if wk_day = 1 then MDY_sas = MDY_sas + 1; output;

Holiday_name = 'LABOR DAY'; MDY_sas = intnx('week.2',mdy(8,31,year),1); /* 1ST MONDAY SEPT */ output;

Holiday_name = 'THANKSGIVING DAY'; MDY_sas = intnx('week.5',mdy(10,31,year),4); /* 4TH THRSDY NOV */ output;

Holiday_name = 'CHRISTMAS'; MDY_sas = mdy(12,25,Year); /* DECEMBER 25TH */ Wk_Day = weekday(MDY_sas); if Wk_Day = 7 then MDY_sas = MDY_sas - 1; else if wk_day = 1 then MDY_sas = MDY_sas + 1; output; END; RUN;

PROC SQL; SELECT YEAR,HOLIDAY_NAME, MDY_SAS FORMAT = DATE9. LABEL = 'HOLIDAY ON' AS FORMAT1, MDY_SAS FORMAT = MMDDYY8. LABEL = 'HOLIDAY2 ON' AS FORMAT2 FROM HOLIDAYS; QUIT;

hope it helps someone later :-) Vasanth.S *

On Thu, Apr 5, 2012 at 8:18 PM, <art297@rogers.com> wrote:

> Howard, > > Good question (as always) and nice page. The paper that Matt, Xia and I > are presenting at this year's SGF won't help Vasanth, as it requires 9.2 or > newer (as Mike pointed out), but nicely complements your page. Would you > mind if I added a link to it on that page? > > Art > ------------------------------ > *From:* Howard Schreier <hs@howles.com> > *To:* Vasanth S <vasanthz@GMAIL.COM>; Mike Zdeb <mike.zdeb@gmail.com>; > Arthur Tabachneck <art297@ROGERS.COM> > *Sent:* Thursday, April 5, 2012 10:37:56 AM > > *Subject:* Re: SAS : Help in 'dating' > > How about holidays falling on Saturday or Sunday? Should they be shifted > to adjacent weekdays? > > http://www.sascommunity.org/wiki/Generating_Holiday_Lists > > >


Back to: Top of message | Previous page | Main SAS-L page