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
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
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".
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
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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.