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 !

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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