I am trying to convert a date currently in character form to correct format, but my code is changing the date. Could anyone please point out what I am doing wrong?
mthyr_birth (existing data)
Jun2001
Feb1954
Feb1984
My code:
data want;
set have;
mthyr_birth2 = input(mthyr_birth, MONYY.);
format mthyr_birth2 MONYY.;
run;
mthyr_birth2 (output)
JUN20
FEB19
FEB19
Many thanks
By default, the MONYY uses a width of 5. So the INPUT function is reading only 5 characters. Your data has 7 characters in it, so change MONYY to MONYY7 and you should see better results.
By default, the MONYY uses a width of 5. So the INPUT function is reading only 5 characters. Your data has 7 characters in it, so change MONYY to MONYY7 and you should see better results.
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!
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.