BookmarkSubscribeRSS Feed
RHL
Calcite | Level 5 RHL
Calcite | Level 5
I'm trying to create a macro variable in the form of 'yyyy-mm-dd' to pass to a DB2 query in a PROC SQL pass-thru query.

I use the following code to get the date, but don;t know how to include the quotes that DB2 requires.

data _null_;
filedate = today() - 1;
filedt = put(filedate,yymmdd10.);
call symput('fdate',filedt);
run;

Can anybody show me how to come up with a macro variable that includes the quotes?

Thanks.
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Use a concatenation in your CALL SYMPUT so you surround the "formatted" date, as shown below (I use asterisks, not vertical bars for a concatenation - no default codepage problem when sending code via FTP)):

data _null_;
CALL SYMPUT('myvar','"' !! put(today(),yymmdd10.) !! '"');
run;
%put &myvar;

Scott Barry
SBBWorks, Inc.
RHL
Calcite | Level 5 RHL
Calcite | Level 5
Thanks. That really helped. It's amazing how simple the solution is to a problem I've tried to solve the whole afternoon!
ChrisNZ
Tourmaline | Level 20
Also,
[pre]
data _null_;
CALL SYMPUT('myvar',quote(put(today(),yymmdd10.)));
run;
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
  • 3 replies
  • 2823 views
  • 0 likes
  • 3 in conversation