Hi all,
is there a way to assosciate numbers from 1 to 12 with the 12 months without having to down the long-winded road of
if x = 1 then my_month = 'JAN';
else if x=2 then my_month = 'FEB';
...
else if x=12 then my_month = 'DEC'
?
Thanks,
Marco
put(mdy(x,1,1960),monname3.)
put(mdy(x,1,1960),monname3.)
Thanks!
but why 1960?
the year is actually irrelevant but that's the year for sas date = 0.
How about:
my_month = put(mdy(x,1,2013),monname3.);
MDY takes a month number, day number, and year. In your case, the day and year can be anything.
Chris
Absolutely.
One way of many is to code a proc format that contains the values.
For example (untested):
proc format;
value myname
1 = "JAN"
2 = "FEB"
etc....
other = "err" /* in case you have a number greater than 12, missing or zero */
;
run;
............................
my_month = put(x,myname.);
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.