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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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