Hello,
I have a problem with something that should be very simple:
I have two variables that are both years. The first one is year4 format, and the second one is BEST12.
All I want is to make a new variable that is these two years substracted from each other, but I just get a wierd number that I can't explain.
I have tried making the BEST12 years into year4 format, but then they all become 1965, I have no idea why!
What can I do?
I have also tried the other way around without luck.
Hi @NLIL I would assume a variable showing a year value with yearw. format is actually a SAS date value rather. Therefore to compute difference in years, you would need to extract year from the SAS date value i.e year(diag_year) and then subtract
So
diag_age = year(diag_year) - birth_year;
Thanks!
The first variable in year4. format:
Diag_year
2000
1995
2003
and so on...
Next variable in best12 format:
birth_year:
1996
1987
2000
and so on
I just want to say:
diag_age = diag_year - birth_year;
Hi @NLIL I would assume a variable showing a year value with yearw. format is actually a SAS date value rather. Therefore to compute difference in years, you would need to extract year from the SAS date value i.e year(diag_year) and then subtract
So
diag_age = year(diag_year) - birth_year;
THANK YOU! ![]()
You're welcome 🙂
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.