BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
crashz204
Calcite | Level 5

In my code I am trying to use the passthrough to Teradata with SAS to automate a report. This automation i have defined dates.

in my Proc SQL using the Teradata passthrough  i refer to the CW_START and CW_END dates for a weekly report. However this doesnt work in the passthrough even though I formatted the dates as YYMMDD10.

Not sure what I am doing incorrectly here so any pointers would help immensely. Thank you!

 

Data DATES;
Format CW_START
CW_END
REPORTDATE
CURR_REPT_DATE
YYMMDD10.;

REPORTDATE = today()-1;
CURR_REPT_DATE = today();
CW_START = intnx('Week.4',ReportDate,0,'B');
CW_END = intnx('Week.4',ReportDate,0,'E');

Call Symput('REPORTDATE',REPORTDATE);
Call Symput('CW_START',CW_START);
Call Symput('CW_END',CW_END);
Call Symput('CURR_REPT_DATE',CURR_REPT_DATE);

run;

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

To specify a date value in Teradata you should be able to use syntax like:

'2019-06-17'

Or be more precisely like

DATE'2019-06-17'

Notice that Teradata uses only single quote characters around literal values.  Double quote characters are used around the names of objects (variables, tables, etc).  But the SAS macro processor will not resolve macro variable references inside of single quotes.

 

So it is probably easiest to add the single quotes when you create the macro variable.

call symputx('CW_START',quote(put(CW_START,yymmdd10.),"'");

 Then use the macro directly in your pass thru Teradata code.

where date_var <= &cw_start

View solution in original post

3 REPLIES 3
ehmsoleil
Fluorite | Level 6

Try removing the format before you use the call symput. 

Re-format in your final product. 

Dates in macro variables can be tricky!

Tom
Super User Tom
Super User

To specify a date value in Teradata you should be able to use syntax like:

'2019-06-17'

Or be more precisely like

DATE'2019-06-17'

Notice that Teradata uses only single quote characters around literal values.  Double quote characters are used around the names of objects (variables, tables, etc).  But the SAS macro processor will not resolve macro variable references inside of single quotes.

 

So it is probably easiest to add the single quotes when you create the macro variable.

call symputx('CW_START',quote(put(CW_START,yymmdd10.),"'");

 Then use the macro directly in your pass thru Teradata code.

where date_var <= &cw_start
crashz204
Calcite | Level 5
Thank You, this worked great!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3617 views
  • 1 like
  • 3 in conversation