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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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