|
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> Trish Bous
> Sent: Thursday, September 23, 2010 4:48 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: WORKING WITH DATES
>
> Hi All,
>
> I am having some trouble looking at the difference in dates and I was
> hoping
> that someone could help. I want to calculate the number of days
> between 2
> dates, and my code works except when the dates are greater than 3 years
> apart. Any help would be appreciated!
>
> Code:
>
>
> data admin;
> set admin;
> by id;
> FORMAT start_DATE DATE8.;
> FORMAT DAYS 8.;
> if first.id then do;
> days=0;
> start_date = DATE;
> end;
>
> else do;
> days = datdif(start_DATE,DATE, 'act/act' );
> end;
> RUN;
>
>
> The output from my code is as follows:
>
>
> Obs ID DATE days start_date DATE
>
> 491 334 03/15/2005 617 07JUL03 03/15/2005
> 492 334 03/21/2005 623 07JUL03 03/21/2005
> 493 334 04/19/2005 652 07JUL03 04/19/2005
> 494 332 05/10/2002 0 10MAY02 05/10/2002
> 495 332 08/20/2002 102 10MAY02 08/20/2002
> 496 332 03/08/2002 -63 10MAY02 03/08/2002
> 497 332 12/13/2005 1E3 10MAY02 12/13/2005
> 498 332 12/12/2005 1E3 10MAY02 12/12/2005
> 499 348 09/28/2001 0 28SEP01 09/28/2001
> 500 354 05/17/2004 0 17MAY04 05/17/2004
>
> As you can see, my problem is with observations 497 and 498, where the
> number of days are "1E3"
>
> I have tried to format the variable, but still no luck.
>
Trish,
Why not just subtract?
Days = date-start_date;
Dan
Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204
|