Suppress variable labels in SAS procedures

Sometimes a small option can make a big difference. Last week I thought to myself, "I wish there were an option that prevents variable labels from appearing in a table or graph." Well, it turns out that there is!

I was using PROC MEANS to display some summary statistics, and the output was starting to get quite wide. For example, the following table has eight columns, including the labels for each variable:

proc means data=sashelp.iris N Mean StdErr CLM Std;
var SepalLength SepalWidth;
run;

Now, I'm sure that the procedure "means" well (pun intended), but I don't need to see the labels for these variables. I can probably remember that the SepalLength variable is a measurement of the "Sepal Length"! On a whim, I searched for the terms "PROC MEANS" and "NOLABEL" and—Awesome!—was led to a SAS Knowledge Base article entitled "New option to suppress variable labels in PROC MEANS."

It turns out that PROC MEANS supports a NOLABELS option, which means that I can suppress the unnecessary column of output:

proc means nolabels data=sashelp.iris N Mean Std StdErr CLM;
var SepalLength SepalWidth;
run;

But it turns out that my good fortune was just beginning. The same article mentions that there is a NOLABEL global system option that suppresses the use of labels in all SAS procedures until you enable the option again. This means that I no longer have to use a LABEL= data set option within each procedure. For example, if I want the variable names to appear on the axis of a ODS graphic, I used to write statements like the following:

proc sgplot data=sashelp.iris;
label SepalLength= SepalWidth=;  /* <== suppress labels for these variables */
scatter x=SepalLength y=SepalWidth / group=Species;
run;

However, with the NOLABEL option, I can write this more succinctly:

options nolabel;   /* <== suppress labels for all variables */
proc sgplot data=sashelp.iris;
scatter x=SepalLength y=SepalWidth / group=Species;
run;

In a similar way, I can suppress the labels in parameter estimate tables and other tables output by SAS procedures:

options nolabel;   /* <== suppress labels for all variables */
proc reg data=Sashelp.iris;
   model SepalLength = SepalWidth / clb stdb;
   ods select ParameterEstimates;
run;
options label;     /* <== re-enable labels */

I like it. So here's a big "shout out" to whomever at SAS was involved in implementing this option. Sometimes a small option can makes a big difference.

tags: Getting Started, SAS Programming

One Comment

  1. anonymous
    Posted August 17, 2012 at 10:21 am | Permalink

    You can remove labels from a list of variables using the ATTRIB statement.

    attrib covar: label=' ';
    attrib _all_ label=' ';

    This is more concise than the LABEL statement and more specific than the system option.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <p> <pre lang="" line="" escaped=""> <q cite=""> <strike> <strong>