The FORMAT Procedure

A Word About PROC FORMAT

The FORMAT procedure stores user-defined informats and formats as entries in SAS catalogs. Formats determine how variable values are printed. For example, when the PRINT procedure displays the data set Work.Carsurvey, notice that the values for Sex, Income, and Color appear as numbers and letters, and therefore they are not easy to interpret.
Figure 8.1 Work.Carsurvey Data Set (partial output)
Work.Carsurvey Data Set
This chapter shows how to display more descriptive values for these variables.

The PROC FORMAT Statement

To begin a PROC FORMAT step, you use a PROC FORMAT statement.
Syntax, PROC FORMAT statement:
PROC FORMAT <options>;
options includes the following:
  • LIBRARY=libref specifies the libref for a SAS library to contain a permanent catalog of user-defined formats
  • FMTLIB displays a list of all of the formats in your catalog, along with descriptions of their values.
Anytime you use PROC FORMAT to create a format, the format is stored in a format catalog. If the SAS library does not already contain a format catalog, SAS automatically creates one. If you do not specify the LIBRARY= option, the formats are stored in a default format catalog named Work.Formats.
The libref Work signifies that any format that is stored in Work.Formats is a temporary format; it exists only for the current SAS session.

Permanently Storing Your Formats

To store formats in a permanent format catalog named Library.Formats:
  • Specify a LIBNAME statement that associates the libref with the permanent SAS library in which the format catalog is to be stored.
    libname library 'c:sasformatslib';
  • Specify the LIBRARY= option in the PROC FORMAT statement and specify the libref Library.
    PROC FORMAT LIBRARY=library;
    Note: If you omit the LIBRARY=option, then formats and informats are stored in the Work.Formats catalog.
    The LIBRARY= option accepts a libref and a catalog in the format library.format. When the LIBRARY= option specifies a libref and not a catalog, PROC FORMAT uses the catalog Formats.
When you associate a permanent format with a variable in a subsequent DATA or PROC step, use the Library libref to reference the location of the format catalog.
Any format that you create in this PROC FORMAT step is now stored in a permanent format catalog called Library.Formats.
libname library 'c:sasformatslib'; 
proc format library=library; 
   ...more SAS statements...  
run;
In the program above, the catalog Library.Formats is located in the SAS library c:sasformatslib, which is referenced by the libref Library.
Notice that LIB= is an acceptable abbreviation for the LIBRARY= option.
proc format lib=library;
Last updated: January 10, 2018
..................Content has been hidden....................

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