Hello team,
I have a column of date which is all numeric, they are not characters. I need to format it as mm/dd/yyyy.
I do what I can, this doesn't get resolved.
the result has to be 10/24/1999
Regards,
Blue & Blue
If the value is numeric you just need to change the actual number involved to a date value and apply a format.
One example:
data example; x = 20191024; x = input(put(x,f8.),yymmdd8.); format x mmddyy10.; run;
Which is easier than parsing out the month, day and year with other methods.
Caveat: if you have single digit month or day: 201911 (instead of 20190101) then you have more work to do.
If the value is numeric you just need to change the actual number involved to a date value and apply a format.
One example:
data example; x = 20191024; x = input(put(x,f8.),yymmdd8.); format x mmddyy10.; run;
Which is easier than parsing out the month, day and year with other methods.
Caveat: if you have single digit month or day: 201911 (instead of 20190101) then you have more work to do.
Hello teammate,
This response saved my life. Thank you very much for it.
I need to know what
put(x,f8.)
do.
Thanks for the response.
blue & blue
The INPUT() function converts strings into values based on the informat being used.
But your variable is numeric, not a character strings. So the PUT() function converts values into strings, based on the format being used. The 8. format tells SAS to format the number as an 8 digit string.
Hello Tom,
What a great response.
Thanks,
Blue & Blue
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.