简体   繁体   中英

How can I convert a .sql file into a SAS dataset?

I have a .sql file which contains information about a database. This database has exactly 8 tables. I would like to essentially import the contents of these 8 tables into SAS and create .sas7bdat SAS datasets.

Is there a quick/easy way to do this directly? I apologize in advance for my lack of database knowledge!

Open the .SQL file with your favourite text editor. You'll see the Create Table and Insert code. You can move those into a PROC SQL step. You may need some minor changes to the code, but should be relatively straight forward, if you have 8 tables it's doable but a little bit of work.

Otherwise you can do as others have mentioned and create a SQL DB.

Use the database and connect to it:

  1. Start SQL Server and SQL Server Management Studio
  2. Run the .sql file in SSMS in a new database.
  3. Connect SAS to SQL Server using SAS/Connect (or some other method)
  4. I would then read the tables in using proc sql , but there are other ways you can access them.

You have to query the sql database and then forward all the results to sas.
That's by far the simplest way.

You just need to setup sql and sas like you normally would and write a program that would copy the contents. It should be easy for a programer that worked with databases.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM