使用列名称中的空格Proc SQL

PNP*_*vir 1 sql sas 4gl

如何在SAS的PROC SQL中使用名称('库名称')中的空格列?

proc sql outobs=10;
    select *
    from sashelp.vtable 
    where library name = xxx
    ;
run;
Run Code Online (Sandbox Code Playgroud)

我试过了:

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;
Run Code Online (Sandbox Code Playgroud)

错误:在贡献表中找不到以下列:test_lin.

sashelp.vtable

变量名称:libname

变量标签:库名称

Y.B*_*.B. 8

根据文档 - SAS Name Literals:

proc sql outobs=10;
    select *
    from sashelp.vtable 
    where 'library name'n = xxx
    ;
run;
Run Code Online (Sandbox Code Playgroud)

一个SAS名称文字是表达为引号内的字符串,然后由大写或小写字母的名称标记ñ....您只能对变量,语句标签和DBMS列和表名使用名称文字.

  • @pnptestovir:我猜库名只是标签名,不是变量名,而是尝试使用libname.或者在vtable上执行proc内容来验证.EDIT:用proc内容检查它,库名只是标签,要访问它你必须使用变量名是libname (2认同)