Date: Fri, 2 Oct 1998 09:59:33 GMT
Reply-To: Bruce Rogers <B.Rogers@VIRGIN.NET>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Bruce Rogers <B.Rogers@VIRGIN.NET>
Organization: Deja News - The Leader in Internet Discussion
Subject: Re: Converting a funky date value to SAS date value
In article <OqJvizV79GA.169@rpc1284.daytonoh.ncr.com>,
"Brian Bachman" <brian.bachman@charlottenc.ncr.com> wrote:
> Hope someone can help me.
>
> I received a file from a colleague that has date stored in the following
> example string 199636, where the first 4 chars are year and the last 2 are
> the week number from that year. I have the need to derive a SAS date value
> such that the resultant value represents the Sunday of each corresponding
> week's end. I have a feeling I am talking about messing with the intnx and
> intck functions but, before I expend too many brain cells on this (as they
> are obviously in short supply here), I wanted to see if anyone has an answer
> to this...
This should be fairly straightforward. Assuming your date is in char var
MYDATE.
/* first statement mulitplies week num by 7 and inputs as julian date */
realdate =
input(substr(mydate,1,4)||put((input(substr(mydate,5,2),2.)*7),z3.),julian7.)
;
/* if this isn't a Sunday, then adjust by adding the required days on */
if weekday(realdate) > 1 then realdate = realdate + (8-weekday(realdate)) ;
If you want the date of the nth Sunday in the year, rather than the Sunday
after the nth full week in the year, the last line should be changed to:
if weekday(realdate) > 1 then realdate = realdate + (1-weekday(realdate)) ;
HTH
Bruce
--
Black Cat Solutions Ltd.
SAS Software Specialists
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
|