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() 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 438 views
  • 0 likes
  • 4 in conversation