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!
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.
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.
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.
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.
Someone at your school will be looking after the SAS installation. Try to find this SAS Admin and get some support.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.