BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
NewUsrStat
Lapis Lazuli | Level 10

Dear all, 

suppose to have two dates: 

Date of Birth: 01JUL1936

Date of Admission: 03MAR2016

The age at admission calculated as: (Date of Admission-Date of Birth)/365.25 = 79.67. 

 

 

Since I need an integer, should this age be rounded to 80 or not? If yes, how? 

 

Thank you in advance

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Should it be rounded? Well, that's up to you, it depends on how you intend to use the result.

 

How to round it?

 

age_rounded = round(yrdif(date_of_birth,date_of_admission,'AGE'));
--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

Should it be rounded? Well, that's up to you, it depends on how you intend to use the result.

 

How to round it?

 

age_rounded = round(yrdif(date_of_birth,date_of_admission,'AGE'));
--
Paige Miller
Kurt_Bremser
Super User
Use the YRDIF function with its default basis of AGE.
Age is not rounded up for the uses I know. You may have different business rules, though, but only you can know them.
PaigeMiller
Diamond | Level 26

Good point, @Kurt_Bremser about not rounding up

To round down, you would use the FLOOR function in SAS

--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 2575 views
  • 1 like
  • 3 in conversation