BookmarkSubscribeRSS Feed
xxformat_com
Barite | Level 11

Hi,

 

The attrib/label statement will only remove the labels of the input variable but not of the statistics computed with proc means.

Is there any option which could  be used to avoid an extra data step/proc datasets?

 

In the example, the N Obs label is first added on the computed nobs variable, and so on.

 

ods exclude all;
ods output summary=test;

proc means data=sashelp.class ;
    class sex;

var height; *attrib _all_ label=' '; run; ods exclude none; proc print data=test label noobs; run; proc datasets lib=work nolist; modify test; attrib _all_ label=' '; run; quit; proc print data=test label noobs; run;

 

16 REPLIES 16
PeterClemmensen
Tourmaline | Level 20

What is the real objective here? To create a report with no labels or to create a data set with statistics with no labels?

xxformat_com
Barite | Level 11
statistics with no label.
PeterClemmensen
Tourmaline | Level 20

In a data set or a report?

 

xxformat_com
Barite | Level 11
no variable label in the dataset as given in the example.
PaigeMiller
Diamond | Level 26

Well, @xxformat_com , you have been asked several times for explanation about what you will do with this "statistic with no label" once you have it. Please provide the answer.

--
Paige Miller
Reeza
Super User
SAS adds variable labels by default. To remove them you can modify the template (which would affect every time you run PROC MEANS), remove them after in the saved dataset using a variety of methods (proc dataset, data step), or ensure the following procedures use variable names not labels. Or explicitly calculate your statistics in a more manual fashion such as proc sql or tabulate where you can control the labels.
PaigeMiller
Diamond | Level 26

@xxformat_com wrote:
statistics with no label.

Please be kind and explain why you want this. Should you achieve this "statistics with no label", what would you do with the resulting statistics with no label, that requires no label and would not work properly if there is a label?

 

I believe that the default label for variables is the variable name.

--
Paige Miller
Tom
Super User Tom
Super User

I really don't understand what the issue is.  If you don't want to print the labels then don't print the labels.

proc print data=test noobs;
run;

Or just skip using ODS output and instead use the OUTPUT statement to generate a dataset. 

That dataset does not add labels.

Tom_0-1669305329006.png

You can also make a wider dataset.

proc means data=sashelp.class nolabels;
  class sex;    var height;
  output out=stats;
  output out=stats_wide n= min= max= mean= std= / autoname ; 
run;

Tom_0-1669313081367.png

 

 

xxformat_com
Barite | Level 11

@tomy Actually I was not expecting any difference between ods output statement and the output statement.

I'm really surprise that both label and format are added to output datasets by default without any possibility to avoid them upfront.

I don't see as beneficially to have to go back to old syntax because of that or add additional steps.

Tom
Super User Tom
Super User

It is normally much better to use the datasets that a procedure can generate.  They are designed to used as data.  The stuff you can capture via ODS is stuff that is designed to be a REPORT.

Ksharp
Super User
Just add this option
options nolabel;
at the top of your code.
xxformat_com
Barite | Level 11

@Ksharp Actually no. Here is an example showing that using the global option is not helping:

options nolabel;
ods exclude all;
ods output summary=test;

proc means data=sashelp.class ;
    class sex;    var height;
    attrib _all_ label=' ';
run;
ods exclude none;
options label;

proc sql;
    select name, format, label
    from dictionary.columns
    where upcase(libname)='WORK' and
          upcase(memname)='TEST';
quit;

proc print data=test label noobs;
run;
ballardw
Super User

@xxformat_com wrote:

@Ksharp Actually no. Here is an example showing that using the global option is not helping:

options nolabel;
ods exclude all;
ods output summary=test;

proc means data=sashelp.class ;
    class sex;    var height;
    attrib _all_ label=' ';
run;
ods exclude none;
options label;

proc sql;
    select name, format, label
    from dictionary.columns
    where upcase(libname)='WORK' and
          upcase(memname)='TEST';
quit;

proc print data=test label noobs;
run;

That actually doesn't "prove" what you may think. Since you are using ODS OUTPUT to create a data set then the rules imposed by that process, ods output, apply which is providing a column heading which makes a lot of sense with the multiple variables that are supported in column with ODS output.

 

Consider

options nolabel;
ods select all;
proc summary data=sashelp.class nway ;
    class sex;    
    var height;
    output out=test2 min= max= std= /autoname;
   
run;

options label;
proc sql;
    select name, format, label
    from dictionary.columns
    where upcase(libname)='WORK' and
          upcase(memname)='TEST2';
quit;
proc print data=test2 label;
run;

The output data set here does not have any "label". SAS will use the variable name as a label when not provided or the option NOLABEL is set.

 

Proc summary calculates all the same statistics as means and creates data sets. In fact for many years Means did not create sets, just print output, and Summary created sets but no print output. The two have been merged and have some slightly different default behaviors to be consistent will older output. The output statement has the AUTOLABEL option to force adding the statistic text to the existing variable label or variable name if not present.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 16 replies
  • 3102 views
  • 4 likes
  • 8 in conversation