Hi,
I have a dataset in which I've created an age variable using a date of birth variable and an "age as of" variable (which I created as well), like this:
/*Calculate age from DOB*/
data want_age;
set have;
ageasof='01NOV2012'D;
run;
DATA create_age;
set want_age;
age=floor(yrdif(datepart(dob), ageasof, age));
run;
The code runs fine and seems to calculate age correctly; however, I get a message after the second step saying that Numeric values have been converted to character values. I want age to be a numeric variable, so this is problematic. However, when I run a proc contents, it says age is already numeric, and when I go to the next step which uses values of age to create age categories, I treat age as numeric and it works fine. I'm confused about why I'm getting the message re: age being converted to character values when that doesn't actually seem to be the case.
Any help is much appreciated.
If you're using the third parameter to YRDIF, it should be character. Try putting "age" in quotes inside the function.
If you're using the third parameter to YRDIF, it should be character. Try putting "age" in quotes inside the function.
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.