BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Rou
Obsidian | Level 7 Rou
Obsidian | Level 7

Hi all,

The age variable in my dataset is reported in days, how do I can convert that to age in years?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

The best way to calculate the age is by using the YRDIF Function with the date of birth and TODAY() as arguments.

From a number of days, use FLOOR(days / 365.25).

 

Edit: added links to the function documentation.

View solution in original post

6 REPLIES 6
Kurt_Bremser
Super User

The best way to calculate the age is by using the YRDIF Function with the date of birth and TODAY() as arguments.

From a number of days, use FLOOR(days / 365.25).

 

Edit: added links to the function documentation.

Rou
Obsidian | Level 7 Rou
Obsidian | Level 7
Thank you!
Hdababs
Obsidian | Level 7

Greetings,

How do I calculate age while using a connection to teradata date of birth field.

 

This is what I tried so far:

PROC SQL;

.

.

..

...

select
DMA.MCID
,frfm.HCC_CD
,DMA.GNDR_NM
,floor ((intck('month',DMA.MBR_BRTH_DT,today()) - (day(today()) < day(DMA.MBR_BRTH_DT))) / 12) as age
,INCRD_YEAR_MNTH_NBR
,case when max(PRORTD_MBR_MNTH_CNT) >0 then 1 else 0 END AS PRORTD_MBR_MNTH_CNT

 

ERROR: Teradata prepare: Syntax error: expected something between '(' and the string 'month'.

 

Hdababs
Obsidian | Level 7

Thank you. I used teradata syntax.

Here is what I used:

('2022' - extract(year from teradata birth date column name)) as Age

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1068 views
  • 3 likes
  • 3 in conversation