BookmarkSubscribeRSS Feed
SARATH_IDBI
Calcite | Level 5

Issue with the below code.
The Report date is not getting matched in the below code. So, no rows are getting updated.

 

%let REPORT_DATE=%sysfunc(putn(%sysevalf(%sysfunc(today()) - 1), yymmddd10.)); */to get yesterday date in YYYY-MM-DD format/*

 

proc sql;
connect to teradata (user="***********" password="*************" server="****************"
mode=teradata);

create table FLOW_YESTERDAY as
select * from connection to teradata
( SELECT * FROM EDWDB.FLOW_ITD
WHERE CAST(T1_DATE AS DATE) = &REPORT_DATE );  */T1_DATE='2021-03-23' gives the required output/*
disconnect from teradata;
quit;

 

proc append base=SASVA.FLOW data=FLOW_YESTERDAY;
run;

 

Please provide a way around.

3 REPLIES 3
SASKiwi
PROC Star

Looks like you need to wrap the macro variable in single quotes but still resolve the value. Here is one way:

%let REPORT_DATE=%sysfunc(putn(%sysevalf(%sysfunc(today()) - 1), yymmddd10.)); */to get yesterday date in YYYY-MM-DD format/*

 

proc sql;
connect to teradata (user="***********" password="*************" server="****************"
mode=teradata);

create table FLOW_YESTERDAY as
select * from connection to teradata
( SELECT * FROM EDWDB.FLOW_ITD
WHERE CAST(T1_DATE AS DATE) = %str(%')&REPORT_DATE%str(%') );  */T1_DATE='2021-03-23' gives the required output/*
disconnect from teradata;
quit;
Kurt_Bremser
Super User

Instead of

%let REPORT_DATE=%sysfunc(putn(%sysevalf(%sysfunc(today()) - 1), yymmddd10.));

do

data _null_;
call symputx("report_date","'"!!put(today()-1,yymmddd10.)!!"'","g");
run;

to add single quotes.

Tom
Super User Tom
Super User

You are comparing your date variable to the formula 2021 minus 3 minus 23 .

Add quotes.

Here is a simple macro to make it easier.

%squote() 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of 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
  • 3 replies
  • 566 views
  • 0 likes
  • 4 in conversation