简体   繁体   English

列名中有空格的 Proc SQL

[英]Proc SQL with space in the column name

How I can use column with space in the name ('library name') in PROC SQL in SAS?如何在 SAS 的PROC SQL中使用名称(“库名称”)中带有空格的列?

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

I tried:我试过:

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.错误:在贡献表中找不到以下列:test_lin。

sashelp.vtable sashelp.vtable

Variable Name: libname变量名: libname

Variable Label: Library Name变量标签: Library Name

According to documentation - SAS Name Literals :根据文档 - 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 . SAS 名称文字是名称标记,表示为引号内的字符串,后跟大写或小写字母n ... You can use a name literal only for variables, statement labels, and DBMS column and table names . ...您只能将名称文字用于变量、语句标签以及DBMS 列和表名称

You need to set DQUOTE=ANSI (default is DQUOTE=SAS ) and then you'll be able to use quotation marks for names: "library name" .您需要设置DQUOTE=ANSI (默认为DQUOTE=SAS ),然后您就可以对名称使用引号: "library name"

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

try to use `` mark... or try to use the bracket []... so it will be like library name or [library name];尝试使用``标记...或尝试使用括号[]...所以它会像library name或[库名];

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

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

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