BookmarkSubscribeRSS Feed
Ivy
Quartz | Level 8 Ivy
Quartz | Level 8

 

%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 .

4 REPLIES 4
cici0017
SAS Employee

Try this -

 

%let cutdt=01jan2011 ;
proc print data = sashelp.cars (obs=10);
title "%upcase(&cutdt)";
run;

BrunoMueller
SAS Super FREQ

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

jklaverstijn
Rhodochrosite | Level 12

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.

Ivy
Quartz | Level 8 Ivy
Quartz | Level 8
Thank you , all, very much, for your help !

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1851 views
  • 1 like
  • 4 in conversation