BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
a_k93
Fluorite | Level 6

Hi everybody,

 

Is there any way / options to view the output of the select * query to display column name instead of column label in the result tab (SAS University Edition)

 

for eg select * from sashelp.cars

it will return the result with the heading as

Make, Model, Type, Origin, DriveTrain, MSRP ,Invoice, Engine Size (L), Cylinders, Horsepower, MPG (City), MPG (Highway), Weight (LBS), Wheelbase (IN), Length (IN)

 

Instead what I am looking is something as below

Make, Model, Type, Origin, DriveTrain, MSRP, Invoice, EngineSize, Cylinders, Horsepower, MPG_City, MPG_Highway, Weight, Wheelbase, Length

 

Thanks,

a_k93

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

While there may be an option for that, I'm not familiar with it. However, here is a way to get around that functionality:

 

proc sql noprint;
  select catx(' ',name,"label=' '")
    into :labels separated by ", "
      from dictionary.columns
        where libname='SASHELP' and
                   memname="CARS"
  ;
quit;


proc sql;
  select &labels.
    from sashelp.cars
  ;
quit;

 

Note: While the above does what the OP asked about, Roger's solution (later in this thread .. using option nolabel) is a better solution.

 

 

HTH,

Art, CEO, AnalystFinder.com

 

View solution in original post

5 REPLIES 5
Shmuel
Garnet | Level 18

Using SAS UE, while you are browsing a dataset, either in OUTPUT DATA or directly in SASHELP.anydata

there is a "view" that enables chose "Column names" or "Column labels".

art297
Opal | Level 21

While there may be an option for that, I'm not familiar with it. However, here is a way to get around that functionality:

 

proc sql noprint;
  select catx(' ',name,"label=' '")
    into :labels separated by ", "
      from dictionary.columns
        where libname='SASHELP' and
                   memname="CARS"
  ;
quit;


proc sql;
  select &labels.
    from sashelp.cars
  ;
quit;

 

Note: While the above does what the OP asked about, Roger's solution (later in this thread .. using option nolabel) is a better solution.

 

 

HTH,

Art, CEO, AnalystFinder.com

 

a_k93
Fluorite | Level 6
Thanks......
rogerjdeangelis
Barite | Level 11
Options
  label and nolabel turns labesl off and on

data class;
 label
    age="Age hs a label"
 ;
 set sashelp.class(keep=name age);
run;quit;

proc sql;
  select
     *
  from
     class
;quit;

  Age hs
 a label  NAME
------------------
      14  Alfred
      13  Alice
      13  Barbara
      14  Carol
      14  Henry


options nolabel;


proc sql;
  select
     *
  from
     class
;quit;

     AGE  NAME
------------------
      14  Alfred
      13  Alice
      13  Barbara
      14  Carol
      14  Henry
      12  James
      12  Jane



options label;


a_k93
Fluorite | Level 6
Thanks Roger.... this is what I was looking for.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 8669 views
  • 3 likes
  • 4 in conversation