|
|
SAS and dates
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: SAS and dates - comp.soft-sys.sasI'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 bee... Comparing start and stop dates - comp.soft-sys.sasHello, I have a problem where i have a popuation taking drugs and there are multiple start and stop dates for each drug. I need to create a any ... date time concatenation - comp.soft-sys.sasHello there, i have two variables (date and time) i want to concatenate these two variables without using concatenation. ... Converting a datetime field to a date without using datepart() in ...Hi, Could I have some advice please as I need to convert a datetime field to a date but I cannot use datepart() and need to use PROC SQL. Woul... Importing dates from excel to SAS - comp.soft-sys.sasDear all: I imported 2 dates from excel to SAS with no apparent problem, via proc contents. However when I calculated age from the dates I am get... Month To Date Calculation - comp.soft-sys.sasHello Group, How can I achieve the Month To Date and Year To Date calculation I was trying Mr. Ian Whitlock macro code ... using proc export/dbms=xls and excel lost date format - comp.soft ...I think it's very weird. And it's very easy to reproduce the problem. SAS 9.2 (32-bit/64-bit) proc export data=whatever_dataset_with_datetime; ... Re: SAS Calculates the number of days between 31DEC9999 and - comp ...Any suggestions about how to change the function to make it mirror exactly how SAS interprets dates? This also seems to have been the cause of various SAS-Excel ... Re: using proc export/dbms=xls and excel lost date format - comp ...using proc export/dbms=xls and excel lost date format - comp.soft ... Re: using proc export/dbms=xls and excel lost date format - comp ... using proc export/dbms=xls ... changing character to numeric - comp.soft-sys.sasI am trying to append two datasets (one and two) that have 6 columns:- Class,Route,Date,Time,Name,Place and Arrival In file one, Time,Arrival an... SAS Learning Module: Using dates in SAS - UCLA Academic Technology ...SAS Learning Module Using dates 1. Reading dates in data. This module will show how to read date variables, use date functions, and use date display formats in SAS. SAS ORKING ITH ATE AND IME UNCTIONS Andrew H. Karp Sierra ...WORKING WITH SAS ® DATE AND TIME FUNCTIONS Andrew H. Karp Sierra Information Services, Inc. San Francisco, California USA Introduction Many SAS® applications ... 7/24/2012 1:25:13 AM
|
|
|
|
|
|
|
|
|