BookmarkSubscribeRSS Feed
tom12122
Obsidian | Level 7

1. How to convert macro variable from format 2011-01-01 to 01Jan2011.  I know how to do it in data step bud don't know how to do it in macro - i need to use reformatted macro variable in a macro and use it with changed format for PROC SQL purposes.

Working data step:

data _null_;

data = '2011-01-24';

data = INPUT(data, yymmdd10.);

FORMAT data1 DATE9.;

put data ;

run;

Please help to executa that in macro in order to get changed &date macro variable with the same name.

2 REPLIES 2
FloydNevseta
Pyrite | Level 9

How about:

data _null_;
dt = '2011-01-24';
data = INPUT(dt, yymmdd10.);
call symput( 'data', put( data, date9. ));
run;

%put &data;

Patrick
Opal | Level 21

Are you after something like below?

%let HaveDateString=2011-01-01;

%let WantDateString=%sysfunc(inputn(&HaveDateString,yymmdd10.),date9.);

%put WantDateString= &WantDateString;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 2 replies
  • 9864 views
  • 1 like
  • 3 in conversation