COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### SAS and dates

• Follow

I'm an Masters level student working on my thesis. I am trying to
figure out how to do this.

So basically I want to know how long has a person been living with a
disease on the day he/she took the survey. So I have the date that the
person has been diagnosed with a disease and the date the person took
the survey.
both dates are in datetime22.3 format and informat.

I know SAS keeps dates by the number of days since (or before) a
certain date.

So I figure to find out my question I would do:

LengthDisease=datesurveytaken-datediseasedx;

I figure that would give me days and i want this in years, so I would
do:

LengthDisease1=LengthDisease/365;

I get really odd results.

For my first case i get LengthDisease=34883200 and
LengthDisease1=68173.

I think my logic on getting this data makes sense. But clearly a 31
year old person would not have the disease for 68173 years.  So I am
unsure what i am doing wrong to get this data... I am hoping someone
on this message board can help.

 0
Reply Tan 3/31/2010 5:11:59 PM

On Mar 31, 1:11=A0pm, Tan <tan.p.p...@gmail.com> wrote:

> I know SAS keeps dates by the number of days since (or before) a
> certain date.

Datetimes are in seconds; not in days.

--
Paige Miller
paige\dot\miller \at\ kodak\dot\com

 0
Reply Paige 3/31/2010 5:55:38 PM

You should use the DATEPART() and INTCK() functions. DATEPART()
extracts the date portion of a date/time field, while INTCK()
calculates the amount of time between two dates.

Example:  Daydiff =3D
INTCK('day',DATEPART(datesurveytaken),DATEPART(datediseasedx));

http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a0002=
12868.htm

Hope that helps....

Keith

On Mar 31, 1:11=A0pm, Tan <tan.p.p...@gmail.com> wrote:
> I'm an Masters level student working on my thesis. I am trying to
> figure out how to do this.
>
> So basically I want to know how long has a person been living with a
> disease on the day he/she took the survey. So I have the date that the
> person has been diagnosed with a disease and the date the person took
> the survey.
> both dates are in datetime22.3 format and informat.
>
> I know SAS keeps dates by the number of days since (or before) a
> certain date.
>
> So I figure to find out my question I would do:
>
> LengthDisease=3Ddatesurveytaken-datediseasedx;
>
> I figure that would give me days and i want this in years, so I would
> do:
>
> LengthDisease1=3DLengthDisease/365;
>
> I get really odd results.
>
> For my first case i get LengthDisease=3D34883200 and
> LengthDisease1=3D68173.
>
> I think my logic on getting this data makes sense. But clearly a 31
> year old person would not have the disease for 68173 years. =A0So I am
> unsure what i am doing wrong to get this data... I am hoping someone
> on this message board can help.


 0
Reply billyk43 3/31/2010 7:32:59 PM

2 Replies
303 Views

(page loaded in 0.057 seconds)

Similiar Articles:

7/24/2012 1:25:13 AM

 Reply: