Assigning Descriptive Labels

Temporarily Assigning Labels to Variables

To enhance your PROC PRINT by labeling columns:
  • Use the LABEL statement to assign a descriptive label to a variable.
  • Use the LABEL option in the PROC PRINT statement to specify that the labels be displayed.
Syntax, LABEL statement:
LABEL variable1='label1'
variable2='label2'
... ;
Labels can be up to 256 characters long. Enclose the label in quotation marks.
Tip:The LABEL statement applies only to the PROC step in which it appears.

Example: Using the LABEL Option in the PROC PRINT Statement

In the PROC PRINT step below, the variable name WalkJogRun is displayed with the label Walk/Jog/Run. Note that the LABEL option is in the PROC PRINT statement.
proc print data=cert.therapy label;
  label walkjogrun='Walk/Jog/Run';
run;
Output 6.12 PROC PRINT Output with LABEL Option (partial output)
Partial Output: PROC PRINT Output using the LABEL option in the PROC PRINT statement
If you omit the LABEL option in the PROC PRINT statement, PROC PRINT uses the name of the column heading, walkjogrun, even though you specified a value for the variable.

Example: Using Multiple LABEL Statements

The following example illustrates the use of multiple LABEL statements.
proc print data=cert.admit label;       /*#1*/
  var age height;
  label age='Age of Patient';           /*#2*/
  label height='Height in Inches';      /*#3*/
run;
1 Use the LABEL option with the PROC PRINT statement. If you omit the LABEL option in the PROC PRINT statement, PROC PRINT uses the variable name.
2 You can assign labels in separate LABEL statements. In this example, label the variable Age as Age of Patients.
3 This is the second LABEL statement in this example. Label the variable Height as Height in Inches.
Output 6.13 PROC PRINT Output with Multiple LABEL Statements (partial output)
PROC PRINT Output with Multiple LABEL Statements (partial output)

Example: Using a Single LABEL Statement to Assign Multiple Labels

You can also assign multiple labels using a single LABEL statement.
proc print data=cert.admit label;         /*#1*/
  var actlevel height weight;
  label actlevel='Activity Level'         /*#2*/
        height='Height in Inches'
        weight='Weight in Pounds';
run;
1 Use the LABEL option with the PROC PRINT statement.
2 A single LABEL statement assigns three labels to three different variables. Note that you do not need a semicolon at the end of your label until you are ready to close your LABEL statement. In this example, the semicolon is at the end of the label for Weight.
Output 6.14 PROC PRINT Output with a Single LABEL Statement (partial output)
PROC PRINT Output with a Single LABEL Statement (partial output)
Last updated: August 23, 2018
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.131.38.14