%let cutdt = '01jan2011'd ;
I would like to get a macro value as 01Jan2011 or Jan 01, 2011 from &cutdt .
Is there any converted function ?
Thank you very much .
Try this -
%let cutdt=01jan2011 ;
proc print data = sashelp.cars (obs=10);
title "%upcase(&cutdt)";
run;
Hi
I recommend to store just the date as DATE9. value in a macro variable. From there all sorts use uses are possible.
Have a look at the sample code below.
%let cutdt = 01jan2011;
* use as date constant ;
data want;
somedate = "&cutdt"d;
format someDate worddate.;
run;
* a new formatted date value as text;
%let newDate = %sysfunc( putn(%sysevalf("&cutdt"d), ddmmyyp10.));
title "Date as of &newDate";
proc print data=want;
run;
Bruno
You can do the conversion in a datstep:
%let cutdt = '01jan2011'd ;
data _null_;
dt=&cutdt;
call symput ('date1', put(dt, date9.));
call symput ('date2', put(dt, worddate12.));
run;
%put &=date1;
%put &=date2;
I believe %SYSFUNC could also be used, bypassing the datastep, but an example doesn't comes to mind.
Hope this helps,
- Jan.
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.