I have a variable DATE that has a value of 2012-04-05. How do I convert that value into 05Apr2012?
Christos
Hi,
From your description, it is difficult to tell whether you want to change format for a numeric variable(dt1) or you want to make change on a character variable(dt2). Any way, the following example addressed both.
data have;
input dt1 yymmdd10. @1 dt2 $10.;
format dt1 yymmdd10.;
cards;
2012-04-05
run;
data want;
set have;
format dt1 date9.;
dt2=put(input(dt2,yymmdd10.),date9.);
run;
proc print;run;
Haikuo
Hi,
From your description, it is difficult to tell whether you want to change format for a numeric variable(dt1) or you want to make change on a character variable(dt2). Any way, the following example addressed both.
data have;
input dt1 yymmdd10. @1 dt2 $10.;
format dt1 yymmdd10.;
cards;
2012-04-05
run;
data want;
set have;
format dt1 date9.;
dt2=put(input(dt2,yymmdd10.),date9.);
run;
proc print;run;
Haikuo
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.