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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 1926 views
  • 0 likes
  • 3 in conversation