Home » How to Remove Variable Labels in SAS (With Examples)

How to Remove Variable Labels in SAS (With Examples)

by Tutor Aspire

You can use the following methods to remove variable labels in SAS:

Method 1: Remove Label from One Variable

proc datasets lib=work;
  modify original_data;
  attrib my_variable label='';

Method 2: Remove Label from All Variables

proc datasets lib=work;
  modify original_data;
  attrib _all_ label='';

The following examples show how to use each method in practice with the following dataset that has three variables with a label for each variable:

/*create dataset*/
data original_data;
   label x='REBOUNDS'
         y='POINTS'
         z='ASSISTS';
   input x y z;
datalines;
6 22 5
8 14 9
9 31 10
9 40 7
3 12 3
2 20 5
;

/*view contents of dataset*/
proc contents data=original_data;

Example 1: Remove Label from One Variable

The following code shows how to use proc datasets to remove the label from just the variable called ‘x’ in our dataset:

proc datasets lib=work;
  modify original_data;
  attrib x label='';

Notice that the label has been removed from variable x while the other variables in the dataset have remained unchanged.

Example 2: Remove Label from All Variables

The following code shows how to use proc datasets to remove the label from all variables in the dataset:

proc datasets lib=work;
  modify original_data;
  attrib _all_ label='';

Notice that the labels for all of the variables in the dataset have been removed.

Note: You can find the complete documentation for proc datasets here.

Additional Resources

The following tutorials explain how to perform other common tasks in SAS:

How to Normalize Data in SAS
How to Identify Outliers in SAS
How to Extract Numbers from String in SAS
How to Remove Leading Zeros in SAS

You may also like