UMASS Department of:
Biostatistics and Epidemiology

SAS:The Statistical Analysis System
Basics
Combo
Desc Stats
Advanced
Index
SASHome
Intro
Data In
Data Out
Pretty
Cleaning
Documentation
Environs
Basics: Making a data set easy to understand, and producing pretty results
Including descriptive names for categories or values (FORMATS).


Introduction

We illustrate how to make column heading easy to understand using a LABEL statement in a SAS DATA step. The illustrations use data read by a simple SAS program that consists of a portion of the full data from a study of Intensive Care.

(Context) Task

Result

SAS Keywords/Code

Detail

2a.Creating formatted values for variable values (Numeric or Character)

Table 2a1, 2a2

PROC FORMAT; VALUE ...
PROC PRINT; FORMAT ;

Details

2b. Using formatted values in PROC FREQ

Table 2b

PROC FREQ;
FORMAT sex sexf. ;

Details

2c. Including formatted values in a SAS data set

Table 2c

DATA ;
FORMAT sex sexf.;

2d. Ignoring formatted values contained in a SAS data set

Table 2d

FORMAT sex ;

2e. Suppressing errors created from Formats in permanent SAS data

Table 2e1, 2e2.

OPTIONS NOFMTERR;

2f. Saving a format CONTROL DATA SET

Table 2f

PROC FORMAT CNTLOUT=

2g. Using a previously saved format CONTROL Data set

Table 2g.

PROC FORMAT CNTLIN=

2h. Updating CONTROL DATA SET

Table 2h.

PROC FORMAT CNTLIN= CNTLOUT= ;

 


Detail for

Result

SAS Keywords/Code

Detail

a.Creating formatted values for variable values

Table 2a

PROC FORMAT; VALUE ...

  • VALUE names must be
    • 8 characters or less
    • end with a character
    • begin with a $ sign if the variable is alphanumeric (character)
    • a good VALUE NAME is the variable name followed by an F (ie. for SEX, use SEXF)
  • formatted values may be up to 40 characters, but many SAS procedures use only 8 characters. Try to keep the value descriptors 8 characters or less (in quotes).
 

 



Detail for

Result

SAS Keywords/Code

Detail

b. Dividing Labels by Lines

Table 1b

PROC PRINT SPLIT="/";..

  • Use a special character in the LABEL statement (either / or *)
  • Include SAS variable name as last part of LABEL
  • Identify the special character with a SPLIT ="/" options in PROC PRINT

 


Basics: Making a data set easy to understand, and producing pretty results
Including descriptive names for categories or values (FORMATS).

CONTEXT: 2a.Creating formatted values for variable values (Numeric or Character)

Although groupings are often represented by numbers in the computer, it is easier to understand the group (male, female) with names. To enhance interpretation of output, we will often want the name of the group to be printed in addition to (or rather than) the group number.

The names for the groups are assigned to the numbers (or other codes) using PROC FORMAT.



Last Update:10/7/98
Comments: Ed Stanek
Email:
stanek@schoolph.umass.edu
\ed\web\be691f\webready\sbpret2.html