BookmarkSubscribeRSS Feed
julrik
Calcite | Level 5
Hello, I am a new user and know only the basic functions of sas and was assigned a project to figure out how to output a SAS dataset to be viewed in MS SQL Server. I have the dataset created, all I need to know is how I can convert that to a table that SQL server is able to open. The best way I can find is exporting the dataset to a csv file and then writing code in SQL to import the CSV file. But seems like that is an extra step that shouldn't have to be taken and because of the 300+ columns in the dataset I don't want to have to define each one in the SQL code. Can anyone help?

Sorry in advance if I posted in the wrong discussion group but this one sounded close to what I want to do.

Thanks
2 REPLIES 2
Cynthia_sas
SAS Super FREQ
Hi,
This is not the right forum for this question. In fact, this is really a question that is best answered by Tech Support. To find out how to contact SAS Tech Support, refer to:
http://support.sas.com/techsup/contact/index.html

and you might also find these previous forum postings and Tech Support Notes to be of interest:
http://support.sas.com/forums/thread.jspa?messageID=2624ੀ
http://support.sas.com/forums/thread.jspa?messageID=1946ޚ
http://support.sas.com/forums/thread.jspa?messageID=4121မ
http://support.sas.com/techsup/unotes/SN/006/006450.html
http://support.sas.com/techsup/unotes/SN/011/011332.html
http://support.sas.com/techsup/unotes/SN/009/009733.html

cynthia
deleted_user
Not applicable
Julrik,

Try something like this, I believe you'll need SAS/Access for MS Sql Server to do this. The libname has certain options and depending on how your system is set up you will have to make adjustments to fit your particular needs.


libname sqlsrvr oledb provider=sqloledb properties=("data source" ='DEV9\DEV9' "Database" ='DEV9'
"Integrated Security" ='SSPI' "initial catalog" ='master')
schema=dbo BCP=YES BCP_ERRORFILE="Z:\error_out.txt";

data SAS_DATA_SET_NAME_HERE ;
set datain;
run;


proc sql;
create table sqlsrvr.SQL_SERVER_TABLE_NAME_HERE as
select * from SAS_DATA_SET_NAME_HERE;
quit;

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
  • 2 replies
  • 670 views
  • 0 likes
  • 3 in conversation