Hi SAS users,
Need help with converting this character date to DATE9 like below.
date1 is the input format data is coming in. Date_out should be '01APR2019'd
data test;
date1 = '2019-04-01' ;
date2 = dequote(date1);
call symputx("date2" , "'"|| input(put(dequote(date1), yymmdd10.),date9.) ||"'d",'g');
run;
%put &date2;
Thanks,
Ana
please try the below code
data test;
date1 = '2019-04-01' ;
call symputx("date2" , cats("'",put(input(date1,yymmdd10.),date9.),"'d"));
run;
%put &date2;
please try the below code
data test;
date1 = '2019-04-01' ;
call symputx("date2" , cats("'",put(input(date1,yymmdd10.),date9.),"'d"));
run;
%put &date2;
Since you need a date literal for use in code, no format us needed:
data test;
date1 = '2019-04-01';
call symputx("date2",input(date1,yymmdd10.),'g');
run;
%put &date2;
See Maxim 28.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.