```Date: Thu, 18 Oct 2007 12:50:31 -0400 Reply-To: Dave Scocca Sender: "SAS(r) Discussion" From: Dave Scocca Subject: Re: first business day of current month Comments: To: BJMurphy In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Ooops--this will teach me to add one more proofreading cycle. My previous example missed properly identifying January 2 when it was not a Tuesday. So the cases for the second and the third are not identical. Dave The corrected version: 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 ; * As is a non-Monday January second ; else if theDay in (2, 3) then do ; if ( theWeekDay=2 and theMonth not in (1, 9) ) or ( theWeekDay=3 and theMonth=9) or ( theDay=2 and theMonth=1 and theWeekDay ne 2 ) then isFirstBusinessDay=1 ; end ; * The third of the month is the first business day if it ; * is a Monday, except in January or on Labor Day ; else if theDay = 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 ; ```

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