| Date: | Wed, 17 Nov 1999 10:57:53 -0500 |
| Reply-To: | laurie_abell@DOFASCO.CA |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Laurie Abell <laurie_abell@DOFASCO.CA> |
| Subject: | Re: recoding some dates |
|
| Content-Type: | text/plain |
|---|
Hi Darin,
Something like this should work (it's been tested with your sample data). It
increments weekend by 1 if there is more than 1 day between consecutive
dates....
data test2(drop=tempdate);
set test;
retain tempdate 0;
if date-tempdate>1 then do;
weekend+1;
tempdate=date;
end;
run;
Laurie
> -----Original Message-----
> From: Darin Erickson [SMTP:erick232@TC.UMN.EDU]
> Sent: Wednesday, November 17, 1999 10:23 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: recoding some dates
>
> I have some data that I cannot seem to figure out how to get into a format
> I
> need. I have a dataset where visits were made to our participants on
> Friday
> and Saturday at different weekends. For example, I may have collected data
> on Friday and Saturday, October 8th and 9th, Friday and Saturday, October
> 22nd and 23rd, and Friday and Saturday, November 5th and 6th. All data
> were
> collected on Friday and Saturday, and usually there was a couple weeks
> separating data collection weekends, although there may be a few instances
> where data were collected on two consequtive weekends. A sample of the
> data
> may look like:
>
> ID Date
> 1 10/8/99
> 2 10/8/99
> 4 10/9/99
> 6 10/9/99
> 2 10/22/99
> 3 10/23/99
> 7 10/23/99
> 1 11/5/99
> 2 11/5/99
> 6 11/5/99
> 8 11/6/99
>
> What I want to get from this data is a variable that tells me what weekend
> each site or participant was visited. This new variable might look like:
>
> ID Date Weekend
> 1 10/8/99 1
> 2 10/8/99 1
> 4 10/9/99 1
> 6 10/9/99 1
> 2 10/22/99 2
> 3 10/23/99 2
> 7 10/23/99 2
> 1 11/5/99 3
> 2 11/5/99 3
> 6 11/5/99 3
> 8 11/6/99 3
>
> Date is formatted as a SAS date (mmddyy8.). I'm stuck - any thoughts?
>
> Thanks, Darin
|