Hi All,
I currently have a variable labeled birthyear (e.g. 1980) and need to create a new continuous age variable. Any help is greatly appreciated!
You need a date to calculate age, not just a year. Would you choose 1 Jan 1980 to base age on (the first day of the period) or some other date?
EDIT: Here's one way you can get a continuous age variable calcuated from 1 Jan 1980:
data Want; Today = today(); Age = yrdif(mdy(1,1, 1980), today(),'AGE'); format Today date9.; put _all_; run; Today=16JAN2023 Age=43.04109589 _ERROR_=0 _N_=1
Calculating an exact age without having month and day is not possible, but if your data is e.g. result of a statistical survey carried out annually, the lack of month and day can be ignored. You may want to post an excerpt of the data you have in usable form an show what you expect as result.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.