Hello Everyone,
I am trying to format a SAS date from MMMYY to MMM-YY (i.e. OCT12 to OCT-12).
This is the code. I can't figure out how to add a - between the month and the year.
Thank you for input you may have!
proc format ;
picture fmt(default=5)
other='%b%y'(datatype=date);
run;
data _null_;
a=23234;
format a fmt.;
put a= ;
run;
Hi,
proc format ;
picture fmt(default=6)
other='%b-%y'(datatype=date);
run;
data want;
a=23234;
format a fmt.;
proc print;run;
Message was edited by:Linlin
Hi,
proc format ;
picture fmt(default=6)
other='%b-%y'(datatype=date);
run;
data want;
a=23234;
format a fmt.;
proc print;run;
Message was edited by:Linlin
Hi Linlin,
Thank you very much for your reply and suggestions! I really learned something new today.
Thank you guys!!
Just include the hyphen in the picture format text. You might also want to look at the built in format NLDATEYM.
proc format ;
picture fmtA(default=5) other='%b%y'(datatype=date);
picture fmtB(default=6) other='%b-%y'(datatype=date);
run;
data _null_;
a='13OCT2012'd ;
put a= date9. / a fmtA. / a fmtB. / a nldateym6. ;
run;
a=13OCT2012
OCT12
OCT-12
Oct 12
Tom,
That worked beautifully! I really appreciate your input and suggestions. That was awesome!!
Thank you again
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.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.