Date: Fri, 23 Jan 2004 09:57:23 -0500 "L. Bertolini" "SAS(r) Discussion" "L. Bertolini" Ohio State University Re: Dates from Excel text/plain; charset=ISO-8859-1; format=flowed

Silvano, When SAS imported the dates from Excel, it stored them as "SAS Datetime" values; i.e., Data and Nasc contain the number of seconds since the "base" (which I think is 01Jan196000:00:00).

To compute an age, in years, you must: 1. convert the "datetime" values to "date" values. (A "date" value is the number of days since the base). 2. Use a formula. I don't remember, but I think this formula came from either the SAS Communications magazine, or from their support web site.

Try something like this:

data_d = datepart(data); nasc_d = datepart(nasc); age=intck('year',nasc_d,data_d) - (month(nasc_d) > month(data_d)) - ((month(nasc_d) =month(data_d))* (day(nasc_d) > day(data_d)));

Silvano Cesar da Costa wrote:

>Hi, > >I imported two dates (Data and nasc_d) from Excel and it looks like: > > Data nasc_d > >02OCT2002:00:00:00 01OCT1999:00:00:00 >04OCT2002:00:00:00 15JUN2002:00:00:00 >10OCT2002:00:00:00 01APR2002:00:00:00 >01OCT2002:00:00:00 01JAN1998:00:00:00 >04OCT2002:00:00:00 20FEB1997:00:00:00 >15SEP2002:00:00:00 18MAR2002:00:00:00 >01OCT2002:00:00:00 18MAR2002:00:00:00 >02OCT2002:00:00:00 12FEB2002:00:00:00 >03OCT2002:00:00:00 01AUG1994:00:00:00 >04OCT2002:00:00:00 04OCT2001:00:00:00 > > >I have 286 data and I would like to calculate the age: AGE = DATA - nasc_d. > >How could I to do this??? Some idea?? > >Thanks a lot, > > >--------------------------------------------------------------- >Silvano Cesar da Costa >Departamento de Matemática Aplicada >Centro de Ciências Exatas >Universidade Estadual de Londrina >Campus Universitário >Cx. Postal 6001 >CEP 86051-990 >Londrina - PR >Fone: (43) 3371 4346 >--------------------------------------------------------------- > >

Back to: Top of message | Previous page | Main SAS-L page