Proc SQL with space in the column name

PNPTestovir picture PNPTestovir · Jun 27, 2016 · Viewed 16.5k times · Source

How I can use column with space in the name ('library name') in PROC SQL in SAS?

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.

sashelp.vtable

Variable Name: libname

Variable Label: Library Name

Answer

Y.B. picture Y.B. · Jun 27, 2016

According to 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.