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 🙂
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!
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.