Proc SQL 列名称中包含 space

Proc SQL with space in the column name

如何在 SAS 的 PROC SQL 中使用名称为 space 的列 ('library name')?

proc sql outobs=10;
    select *
    from sashelp.vtable 
    where library name = xxx
    ;
run;

我试过了:

proc sql outobs=10;
    select *
    from sashelp.vtable 
    where 'Libname'n = test_lin;
quit;

proc sql outobs=10;
    select *
    from sashelp.vtable 
    where 'library name'n = test_lin;
quit;

proc sql outobs=10;
    select *
    from sashelp.vtable 
    where libname = test_lin;
quit;

ERROR: The following columns were not found in the contributing tables: test_lin.

sashelp.vtable

变量名:libname

变量标签:Library Name

根据documentation - SAS Name Literals

proc sql outobs=10;
    select *
    from sashelp.vtable 
    where 'library name'n = xxx
    ;
run;

A SAS name literal is a name token that is expressed as a string within quotation marks, followed by the upper- or lowercase letter n. ... You can use a name literal only for variables, statement labels, and DBMS column and table names.

您需要设置DQUOTE=ANSI(默认为DQUOTE=SAS)然后您就可以使用引号引起来的名称:"library name".

您可以在此处找到详细信息:http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473669.htm

尝试使用``标记... 或者尝试使用括号 []... 所以它会像 library name 或 [图书馆名称];

select *
from sashelp.vtable 
where `library name` = xxx or [library name] = xxx;