BookmarkSubscribeRSS Feed
monona
Obsidian | Level 7

Hello,

 

I am wondering if there is any other way to export sas dataset to ms sql server other than sas_dataset>csv>ms sql dataset manually.

 

I connected to the MS sql server through 

libname ABC odbc noprompt = "server=SQLSVR;driver=SQL server native client 11.0; 
Trusted_connection=yes" database=mydatabase schema=dbo;

However, i haven't understood how this works.

 

I would appreciate any recommendations/tips regarding this problem.

2 REPLIES 2
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

A couple of suggestions:

Use SAS to load a temporary SQL Server table which is then used by the SQL Server load process.
Write a delimited file from SAS then get the SQL Server load process to read the delimited file

https://communities.sas.com/t5/SAS-Data-Management/Load-SAS-Dataset-to-MS-SQL-Server-via-SQL-server-...

 

us the update statement in you datastep or sql statement.

 

Patrick
Opal | Level 21

@monona 

What do you mean by "manually"? Once you've defined the library connecting to the data base you can use it like any other libref.

Code like below would append data from sashelp.class to a table class on your server. It even would create the table in the database if it doesn't exist already.

proc append base=abc.class data=sashelp.class;
run;

The SAS/Access to ODBC documentation will provide you with much more detail.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2766 views
  • 1 like
  • 3 in conversation