BookmarkSubscribeRSS Feed
sobol007
Calcite | Level 5

Hi can anybody help me to finish my thesis please? I need to import data from SQL server to SAS and I´m so bad at it 😞

thx for any help!

5 REPLIES 5
Kurt_Bremser
Super User

The simplest method is to unload your SQL tables into files with a textual format (CSV or fixed column) and then use a proper data step to import the data into SAS.

kannand
Lapis Lazuli | Level 10

Another option....

 

1) connect to your SQL database within your SAS program using the loginid & password defined in a LIBNAME statement 

2) all the SQL tables can be read as SAS files and set using SET statements using the structure "libref.filename".   

 

Alternatively, instead of step 2), you can also use a proc sql to create a SAS file from "CREATE TABLE " syntax reading the SQL Table.

 

Either one should bring you the data. 

Kannan Deivasigamani
Patrick
Opal | Level 21

What does your environment look like?

Are you able to connect to the SQL server via SAS at all - and have you done this before meaning is the environment already set-up?

 

If the environment is already set-up and there is a libname statement pointing to the SQL server then you can use tables in the database for reading as if they were SAS tables.

sobol007
Calcite | Level 5

thx for all response.

 

It can be that the problem is in connection between my SAS acount (at the school) and SQL db. I simplican not to connect to the server.

Patrick
Opal | Level 21

Someone at your school will be looking after the SAS installation. Try to find this SAS Admin and get some support.

 

 

 

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 connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1012 views
  • 1 like
  • 4 in conversation