简体   繁体   English

如何将.sql文件转换为SAS数据集?

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

I have a .sql file which contains information about a database. 我有一个.sql文件,其中包含有关数据库的信息。 This database has exactly 8 tables. 这个数据库正好有8个表。 I would like to essentially import the contents of these 8 tables into SAS and create .sas7bdat SAS datasets. 我想基本上将这8个表的内容导入SAS并创建.sas7bdat SAS数据集。

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. 使用您喜欢的文本编辑器打开.SQL文件。 You'll see the Create Table and Insert code. 您将看到Create TableInsert代码。 You can move those into a PROC SQL step. 您可以将它们移动到PROC SQL步骤中。 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. 您可能需要对代码进行一些小的更改,但是应该相对简单,如果您有8个表,那么它可以做一些工作。

Otherwise you can do as others have mentioned and create a SQL DB. 否则,您可以像其他人提到的那样创建并创建SQL DB。

Use the database and connect to it: 使用数据库并连接到它:

  1. Start SQL Server and SQL Server Management Studio 启动SQL Server和SQL Server Management Studio
  2. Run the .sql file in SSMS in a new database. 在新数据库中运行SSMS中的.sql文件。
  3. Connect SAS to SQL Server using SAS/Connect (or some other method) 使用SAS / Connect(或其他方法)将SAS连接到SQL Server
  4. I would then read the tables in using proc sql , but there are other ways you can access them. 然后我会使用proc sql读取表格,但还有其他方法可以访问它们。

You have to query the sql database and then forward all the results to sas. 您必须查询sql数据库,然后将所有结果转发给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. 您只需要像平常一样设置sql和sas,并编写一个可以复制内容的程序。 It should be easy for a programer that worked with databases. 对于使用数据库的程序员来说应该很容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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