From: Tan on
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.
From: Paige Miller on
On Mar 31, 1:11 pm, Tan <tan.p.p...(a)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
From: billyk43 on

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 =
INTCK('day',DATEPART(datesurveytaken),DATEPART(datediseasedx));


http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a000212868.htm


Hope that helps....


Keith

On Mar 31, 1:11 pm, Tan <tan.p.p...(a)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=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.