The FORMAT Procedure

Definitions

SAS format
determines how variable values are printed according to the data type: numeric, character, date, time, or timestamp.
SAS informat
determines how data values are read and stored according to the data type: numeric, character, date, time, or timestamp.

A Word about PROC FORMAT

SAS provides you with formats and informats that you can use to read and write your data. However, if the SAS formats or informats do not meet your needs, you can use the FORMAT procedure to define your own formats and informats. PROC FORMAT stores user-defined formats and informats as entries in a SAS catalog.
The following output of Work.Carsurvey has a value of 1 or 2 for Sex, and values of B, G, W, and Y for Color. SAS does not provide formats to make the values for Sex and Color easier to read. You can create your own formats to format the values. You can also apply a format to the values of Income.
Figure 12.5 Work.Carsurvey Data Set
Work.Carsurvey Data Set

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 store 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 Formtlib.Formats:
  • Specify a LIBNAME statement that associates the libref with the permanent SAS library in which the format catalog is to be stored.
    libname formtlib 'c:sasformatslib';
  • Specify the LIBRARY= option in the PROC FORMAT statement and specify the libref formtlib.
    PROC FORMAT LIBRARY=formtlib;
    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 user-defined 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 Formtlib.Formats.
libname formtlib 'C:UsersStudent1formatslib'; 
proc format library=formtlib; 
   ...more SAS statements...  
run;
In the program above, the catalog Formtlib.Formats is located in the SAS library C:UsersStudent1formatslib, which is referenced by the libref Formtlib.
Notice that LIB= is an acceptable abbreviation for the LIBRARY= option.
proc format lib=formtlib;
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
18.188.218.157