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.
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;
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.
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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.