FORMAT Procedure

PROC FORMAT Statement

Creates user-specified formats and informats for variables.
Tip: You can use data set options with the CNTLIN= and CNTLOUT= data set options. See Data Set Options for a list.
Creating a Picture Format

Creating a Format from a Data Set

Printing the Description of Informats and Formats

Retrieving a Permanent Format

Syntax

PROC FORMAT <option(s)>;

Summary of Optional Arguments

specifies a SAS data set from which PROC FORMAT builds informats or formats.
creates a SAS data set that stores information about informats or formats that are contained in the catalog specified in the LIBRARY= option.
prints information about informats or formats in the catalog that is specified in the LIBRARY= option.
specifies a SAS library or catalog that contains the informats or formats that you are creating in the PROC FORMAT step.
specifies to create a format catalog that corresponds to the current SAS locale.
specifies the number of characters of the informatted or formatted value that appear in PROC FORMAT output.
specifies the number of characters of the start and end values that appear in the PROC FORMAT output.
prevents a new informat or format from replacing an existing one of the same name.
prints information about each format and informat in the catalog.

Optional Arguments

CNTLIN=input-control-SAS-data-set
specifies a SAS data set from which PROC FORMAT builds informats or formats. CNTLIN= builds formats and informats without using a VALUE, PICTURE, or INVALUE statement. If you specify a one-level name, then the procedure searches only the default library (either the WORK library or USER library) for the data set, regardless of whether you specify the LIBRARY= option.
Note:LIBRARY= can point to either a library or a catalog. If only a libref is specified, a catalog name of FORMATS is assumed.
Tip:A common source for an input control data set is the output from the CNTLOUT= option of another PROC FORMAT step.
CNTLOUT=output-control-SAS-data-set
creates a SAS data set that stores information about informats or formats that are contained in the catalog specified in the LIBRARY= option.
If you are creating an informat or format in the same step that the CNTLOUT= option appears, then the informat or format that you are creating is included in the CNTLOUT= data set.
If you specify a one-level name, then the procedure stores the data set in the default library (either the WORK library or the USER library), regardless of whether you specify the LIBRARY= option.
Note:LIBRARY= can point to either library or a catalog. If only a libref is specified, SAS uses the catalog name FORMATS.
Tip:You can use an output control data set as an input control data set in subsequent PROC FORMAT steps.
FMTLIB
To get information about specific informats or formats, subset the catalog using the SELECT or EXCLUDE statement.
Interaction:The PAGE option invokes FMTLIB.
Tips:If your output from FMTLIB is not formatted correctly in the ODS LISTING destination, then try increasing the value of the LINESIZE= system option.

If you use the SELECT or EXCLUDE statement and omit the FMTLIB and CNTLOUT= options, then the procedure invokes the FMTLIB option and you receive FMTLIB option output.

LIBRARY=libref<.catalog>
specifies a SAS library or catalog that contains the informats or formats that you are creating in the PROC FORMAT step. The procedure stores these informats and formats in the catalog that you specify so that you can use them in subsequent SAS sessions or jobs.
Alias:LIB=
Default:If you omit the LIBRARY= option, then formats and informats are stored in the WORK.FORMATS catalog. If you specify the LIBRARY= option but do not specify a name for catalog, then formats and informats are stored in the libref.FORMATS catalog.
Note:LIBRARY= can point to either a library or a catalog. If only a libref is specified, then SAS uses the catalog name FORMATS.
Tips:SAS automatically searches LIBRARY.FORMATS. You might want to define and use the LIBRARY libref for your format catalog.

You can control the order in which SAS searches for format catalogs with the FMTSEARCH= system option. For more information, see FMTSEARCH= System Option in SAS System Options: Reference.

LOCALE
specifies to create a format catalog that corresponds to the current SAS locale.
The name of the catalog that SAS creates is the SAS library or catalog that is specified in the LIBRARY= option appended with the five character POSIX locale value for the current SAS locale.
See:For a list of POSIX locale values, see LOCALE= Values and Default Settings for ENCODING, PAPERSIZE, DFLANG, and DATESTYLE Options in SAS National Language Support (NLS): Reference Guide.
Example:If the SAS locale is German_Germany, the POSIX locale value is de_DE. Using the following PROC FORMAT statement, SAS creates the catalog mylib.formats_de_DE to store formats and informats created by this procedure:
proc format locale lib=mylib.formats;
MAXLABLEN=number-of-characters
specifies the number of characters in the informatted or formatted value that you want to appear in the CNTLOUT= data set or in the output of the FMTLIB option. The FMTLIB option prints a maximum of 40 characters for the informatted or formatted value.
MAXSELEN=number-of-characters
specifies the number of characters in the start and end values that you want to appear in the CNTLOUT= data set or in the output of the FMTLIB option. The FMTLIB option prints a maximum of 16 characters for start and end values.
NOREPLACE
prevents a new informat or format from replacing an existing one of the same name. If you omit NOREPLACE, then the procedure warns you that the informat or format already exists and replaces it.
Note:You can have a format and an informat of the same name.
PAGE
prints information about each format and informat in the catalog.
Interaction:The PAGE option activates the FMTLIB option.
Tip:In the ODS LISTING destination, the information about each format and informat appears on separate pages in the Output window.