Depends whether your dates are like a, b or c in the following example
data test;
a = 201506; /* YYYYMM as a number */
b = '01JUN2015'd; /* SAS date value with YYYYMM format */
format b yymmn6.;
c = "201506"; /* char version of the YYYYMM date */
run;
proc print; run;
proc sql;
select
mdy(mod(a, 100), 1, int(a/100)) as date_a format=yymmdd6.,
b as date_b format=yymmdd6.,
input(c, yymmn6.) as date_c format=yymmdd6.
from test;
quit;
Result:
FORMAT= as a column option in either SELECT or CREATE statement,
Here you go:
data have;
informat date mmddyy10.;
format date mmddyy10.;
input date;
cards;
10/01/2015
;
run;
proc sql;
create table want as
select date format = date9.
from have;
Depends whether your dates are like a, b or c in the following example
data test;
a = 201506; /* YYYYMM as a number */
b = '01JUN2015'd; /* SAS date value with YYYYMM format */
format b yymmn6.;
c = "201506"; /* char version of the YYYYMM date */
run;
proc print; run;
proc sql;
select
mdy(mod(a, 100), 1, int(a/100)) as date_a format=yymmdd6.,
b as date_b format=yymmdd6.,
input(c, yymmn6.) as date_c format=yymmdd6.
from test;
quit;
Result:
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.