在 SAS Studio 中读取 sas7bdat 文件

STL*_*STL 1 sas

我已经搜索了互联网,但似乎无法弄清楚这一点。我的问题是,如果我有一个 sas7bdat 文件,我如何在 SAS studio 中读取 sas7bdat 文件以便我可以使用它。

我试过了:

libname test 'C:\Users\name\Downloads\test.sas7bdat'; 
Run Code Online (Sandbox Code Playgroud)

这给了我库测试不存在的错误,如果我尝试以下操作,我知道我需要一个我不知道的输入,除非我可以看到文件。

DATA test; 
    INFILE 'C:\Users\lees162\Downloads\test.sas7bdat'; 
RUN; 
Run Code Online (Sandbox Code Playgroud)

有什么我想念的吗?

Tom*_*Tom 5

您通过LIBNAME语句创建的 Libref指向目录,而不是单个文件。

libname test 'C:\Users\name\Downloads\'; 
Run Code Online (Sandbox Code Playgroud)

INFILE用于读取原始数据文件。要引用现有的 SAS 数据集,请使用SET语句(或MERGE, MODIFY,UPDATE语句)。

set test.test ;
Run Code Online (Sandbox Code Playgroud)

请注意,您可以跳过定义 libref 并仅在 SET 语句中使用带引号的物理名称。

DATA test; 
  set 'C:\Users\lees162\Downloads\test.sas7bdat'; 
RUN; 
Run Code Online (Sandbox Code Playgroud)

Of course to use C:\ in the paths this is assuming that you are using SAS/Studio to point to full SAS running on your PC. If you are using SAS University Edition then it is running in a virtual machine and you will need to put the SAS dataset into a folder that is mapped to the virtual machine and then reference it in the SAS code with the name that the virtual machine uses for the directory.

So something like:

DATA test; 
  set '/folders/myfolders/test.sas7bdat'; 
RUN; 
Run Code Online (Sandbox Code Playgroud)