Date: Thu, 18 Oct 2007 12:38:28 -0400
Reply-To: Dave Scocca <dave@SCOCCA.ORG>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Dave Scocca <dave@SCOCCA.ORG>
Subject: Re: first business day of current month
In-Reply-To: <1192723541.301546.214040@k35g2000prh.googlegroups.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
--On 10/18/2007 9:05 AM -0700 BJMurphy wrote:
> mmdd = substr(put(date,mmddyy6.),1,4);
> if (weekday(date) in (1,7)) then date_type = 'w'; /* weekend */
> else if
> (mmdd in ('0101','0704','1111','1225')) or
> (weekday(date) = 2 and
> ((mmdd in ('0102','0705','1112','1226') or
This leaves out the cases when the holiday falls on a Saturday and is
observed on the following Monday: Mondays that are 0103, 0706, 1113, and
1227 are holidays.
> I can't decide the best way to figure out whether today was the first
> business day or not.
You can ignore most of the holidays, as they don't affect the beginning of
the month.
A date ("today") is the first business day of the month IF:
theDate=today() ;
theDay = day(theDate) ;
theMonth = month(theDate) ;
theWeekDay = weekDay(theDate) ;
isFirstBusinessDay = 0 ;
* A day is only a candidate for first-business-day if it is ;
* not a weekend and it is the fourth of the month or earlier ;
if ( (theDay le 4) and (theWeekDay not in (1, 7)) ) then do ;
* A non-weekend first of the month is the first business day ;
* Except in January and on Labor Day ;
if theDay = 1 then do ;
if theMonth not in (1, 9) then isFirstBusinessDay=1 ;
else if theMonth=9 and theWeekDay ne 2
then isFirstBusinessDay=1 ;
end ;
* A Monday second or third of the month is the first business day ;
* Except in January and on Labor Day ;
* A Tuesday second of the month in January or September is also ;
* the first business day ;
else if theDay in (2, 3) then do ;
if ( theWeekDay=2 and theMonth not in (1, 9) ) or
( theWeekDay=3 and theMonth in (1, 9) )
then isFirstBusinessDay=1 ;
end ;
* The fourth is only the first business day when it is Tues Jan 4 ;
* or Tues Sep 4 ;
else if theMonth in (1, 9) and theWeekday=3
then isFirstBusinessDay=1 ;
end ;
Dave
|