BookmarkSubscribeRSS Feed
lzmilman
Calcite | Level 5

Hi:

I am new to the SAS programming.

I need to insert a sas dataset into a SQL server table using a SAS program in the UNIX environment.

I can  create a  connection to the SQL server. Need the command to insert dataset to SQL server table.

Thanks.

4 REPLIES 4
LinusH
Tourmaline | Level 20

If your connection that you have created is a libref, you can also use PROC APPEND.

Data never sleeps
Haikuo
Onyx | Level 15

After seeing other answers, I am now a bit confused about what you were asking for. I thought you asked how to insert(not sure what you mean by that though, suppose Art's answer will cover that) a SAS table into SQL server dataset. If that is the case,  it will be about SAS/ACCESS (depending on what license you have, it could be SQL server, ODBC or OLE DB driver, run proc setinit; to check it.). My suggestion will be:

1. Use either libname engine or other to assign a libref pointing to SQL server workspace, the detailed SAS statements will vary  a little depending on what kind of engine you are using, check SAS docs for more.  Then convert your SAS table into SQL server dataset. It could be as simple as the following:

   data SQL.want; /*SQL server dataset*/

      set SAS.have;/*SAS table*/

run;

2. Then you can use whatever client apps native to SQL server to do the 'insert', or use SAS pass-through.

Haikuo

jonam
Calcite | Level 5

Hi Izmilman,

Inserting in relational database can be done using proc dbload.  SAS/ACCESS provides an interface to do this, provided your site should have the necessary licence to do this.

http://support.sas.com/documentation/cdl/en/acreldb/63647/HTML/default/viewer.htm#a001405617.htm

Hope this helps.

Like native sql server sql.  you don't need to create the structure, inserting separately.  SAS/ACCESS interface provides this functionality. you don't need to worry about defining the datatypes as per sql server.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 4 replies
  • 993 views
  • 0 likes
  • 5 in conversation