BookmarkSubscribeRSS Feed
Tom
Super User Tom
Super User

You are still not communicating clearly.

If the actual value is 18DEC2023:18:48:18 then you have a CHARACTER variable.

 

The most likely cause for getting age of 53 is that you messed up the order of the arguments and which one had DATE values versus DATETIME values so that you ended up calculating the number of years since 1960.  So 53 years would be some time in 2013.

 

Example:

 73         data _null_;
 74           dob = '01JUN2013'd;
 75           date = '01JUN2023'd ; * DATE value, not DATETIME ;
 76           age = yrdif(datepart(date),dob);
 77           put (_all_) (=/);
 78         run;
 
 dob=19510
 date=23162
 age=53.41369863

For this example the real formula should be yrdif(dob,date) which would yield age=10.

emaguin
Quartz | Level 8
"The most likely cause for getting age of 53 is that you messed up the order of the arguments and which one had DATE values versus DATETIME values so that you ended up calculating the number of years since 1960."

YES. That is exactly what I did.

Case closed.

Thank you for your help and persistence and to all who replied, thank you.

Gene Maguin

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 16 replies
  • 1825 views
  • 3 likes
  • 5 in conversation