SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
archibald
Obsidian | Level 7

 

 

Hi,

Using this syntax in SAS    Age= (graduationdate-dob)/365.25;

and using the equivalent in spss   Compute Age= (graduationdate-dob)/365.25.

I get the same exact result. In SPSS, the present code takes into account leap year.

but the issue is  in SAS to accurately calculate age while taking  into acount leap year  the folllowing should be used

        syntax 3- Age= ('year' dob, graduationdate, 'continuous')

OR syntax 3- Age=  intck('year', dob, graduationdate) - (put(dob, mmddyy4.) > put(graduationdate, mmddyy4.)).

However  results  from  syntax3 or syntax4  are not similar to that of the SPSS code.

 

Does anyone know why this  discrepancy? thanks.

5 REPLIES 5
Reeza
Super User

What SPSS code?

 

 

archibald
Obsidian | Level 7
Compute Age= (graduationdate-dob)/365.25.
Reeza
Super User

Then the SPSS code is not accounting for leap years. It is approximately, but not exactly so your SPSS numbers will be incorrect. 

 

This is question was also asked yesterday, 

https://communities.sas.com/t5/Base-SAS-Programming/compute-age-from-two-dates/m-p/278508/highlight/...

 

Theres some links there that go over the differences between the methods and which one is correct. 

PGStats
Opal | Level 21

Syntax 3 should be 

 

Age = INTCK('year', dob, graduationdate, 'continuous')

 

dividing the number of days by 365.25 will give you the correct age sometimes but definitely not always.

PG
archibald
Obsidian | Level 7

good catch. INTCK shjould be includded.

Thanks!

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1678 views
  • 0 likes
  • 3 in conversation