PROC SQL;
SELECT DATE FORMAT MMYYS. FROM TABLE NAME;
QUIT;
This is pretty old, so I dare say not relevant anymore, but this is how I might have done it:
data _null_;
date = 'JAN2010';
format date2 mmyyd7.;
date2 = input(date, monyy7.);
call symput('date', date);
call symput('date2', date2);
run;
%put date=&date. date2=%sysfunc(putn(&date2., mmyyd7.) );
Which outputs:
20 data _null_;
21 date = 'JAN2010';
22 format date2 mmyyd7.;
23 date2 = input(date, monyy7.);
24
25 call symput('date', date);
26 call symput('date2', date2);
27 run;
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
26:25
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
28 %put date=&date. date2=%sysfunc(putn(&date2., mmyyd7.) );
date=JAN2010 date2=01-2010
if you have a CHARACTER variable:
data have;
input date $;
cards;
jan2012
feb2012
;
proc sql;
create table want as select input(date,MonYY7.)
as date format mmyyd7.
from have;
quit;
proc print;run;
Obs date
1 01-2012
2 02-2012
Linlin
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 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.