BookmarkSubscribeRSS Feed
deleted_user
Not applicable
So I’m confused. I am using pass through SQL because I specified the connection and not the lib name. My understanding is I need to format such that Teradata understand the SQL. Which I have done. However I seem to not have done so that SAS will process it. I can not use Teradata sub-commands in pass through ? If not how can I accomplish what I am trying to do below and insert the current timestamp. I can create a data set and build the date and put to a variable, but is the REALLY the best way to do this ?

I get a syntax error because it can not recognize current_timestamp. Any help would be appreciated.

%macro updatingtables;

proc sql;
connect to teradata (user=user password="password"
server=server1 mode=teradata);
execute(INSERT INTO TDDatabase.Tablename
( column1
,column2
,column3
,column4
,column5
,column6
,column7 )
VALUES
("&data1"
,"&data2"
,"&data3"
,"&data4"
,"&data5"
,'COMPLETE'
,CURRENT_TIMESTAMP) );
by teradata;
disconnect from teradata;
quit;

%mend updatingtables;

%updatingtables
1 REPLY 1
deleted_user
Not applicable
I will answer this in the event someone else needs the same information.

a) I had a semicolon incorrectly oustide the parens at the end of my value list
b) I had an issue with needing double quotes to resolve the variable, and needing single quotes for Teradata. The %str lets me resolve the variable and still use single quotes.
c) casting the current_timestamp let me get the value i needed.

I'm relatively new to SAS, and forums like this are invaluable for developers. Hopefully this information is helpful.


%macro updatingtables;

proc sql;
connect to teradata (user=user password="password"
server=server1 mode=teradata);
execute(INSERT INTO TDDatabase.Tablename
( column1
,column2
,column3
,column4
,column5
,column6
,column7 )
VALUES
( %str(%')&data1%str(%')
,%str(%')&data2%str(%')
,%str(%')&data3%str(%')
,%str(%')&data4%str(%')
,%str(%')&data5%str(%')
,'COMPLETE'
,CAST((CURRENT_TIMESTAMP) AS TIMESTAMP(6)); )
by teradata;
disconnect from teradata;
quit;

%mend updatingtables;

%updatingtables

Message was edited by: Sprtsnut Message was edited by: Sprtsnut

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
  • 1 reply
  • 2972 views
  • 0 likes
  • 1 in conversation