Help using Base SAS procedures

Insert a SAS Dataset into a SQL database using passthrough

Reply
N/A
Posts: 0

Insert a SAS Dataset into a SQL database using passthrough

Can I insert data from a sas dataset into a sql table using passthrough? I have a sas dataset called inputdataset. I am using the following code to insert that into the database but the sas dataset is not recognized.

Proc SQL noprint;
Connect to odbc as FTP(required = "Dsn=&DbDsn");
Execute (Insert into ITGCostCurves
Select *, &PeriodDate as TimePeriod from InputDataSet) by FTP;
disconnect from FTP;
quit;
N/A
Posts: 0

Re: Insert a SAS Dataset into a SQL database using passthrough

Posted in reply to deleted_user
Hello pkr,

I'm afraid this won't be possible. With SQL pass through, the sql is executed directly by the database management system (The SQL must follow the syntax in use at dbms level). The dbms has no view on your SAS datasets.

If you want to insert data in a table, the best solution is to connect to the ODBC database using a libname statement. This should look like this:
libname dta ODBC dsn="&DbDsn";

The insert would look like this:
insert into dta.ITGCostCurves .... select ...

The "select" would be in SAS syntax.

Hope this helps,

Yoba Message was edited by: yoba
N/A
Posts: 0

Re: Insert a SAS Dataset into a SQL database using passthrough

Posted in reply to deleted_user
Thank you.
Ask a Question
Discussion stats
  • 2 replies
  • 164 views
  • 0 likes
  • 1 in conversation