Hi All,
I'm relatively new to SAS programming having had experience with MSSQL, MySQL mostly.
I am trying to get the month as a string from a date in the format 'mm'.
For example: 01JAN2017 would result in '01'. 01FEB2017 would result in '02' etc.
I need the preceding 0 for months 1-9
I have been looking at PUT function(?) to do this but cannot find a format that is going to do what I need it to do.
Anyone have any solution or ideas to point me in the right direction?
Try this
data _null_;
dt='01Jan17'd;
mon_val=put(month(dt),z2.);
put mon_val=;
run;
Try this
data _null_;
dt='01Jan17'd;
mon_val=put(month(dt),z2.);
put mon_val=;
run;
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.