FORMAT Procedure

Example 8: Retrieving a Permanent Format

Features:

PROC FORMAT statement options: : LIBRARY=

Other features:

FMTSEARCH= system option

Data set: SAMPLE
This example uses the LIBRARY= option and the FMTSEARCH= system option to store and retrieve a format stored in a catalog other than WORK.FORMATS or LIBRARY.FORMATS.

Program

libname proclib 'SAS-library';
proc format library=proclib;
   picture nozeros
              low   -     -1  =  '00.00' (prefix='-'          )
               -1  <-<     0  =     '99' (prefix='-.' mult=100)
                0   -<     1  =     '99' (prefix='.'  mult=100)
                1   -   high  =  '00.00';
run;
options  fmtsearch=(proclib);
proc print data=sample;
   format amount nozeros.;
   title1 'Retrieving the NOZEROS. Format from PROCLIB.FORMATS';
   title2 'The SAMPLE Data Set';
run;

Program Description

Set up a SAS library reference named PROCLIB.
libname proclib 'SAS-library';
Store the NOZEROS. format in the PROCLIB.FORMATS catalog.
proc format library=proclib;
Create the NOZEROS. format. The PICTURE statement defines the picture format NOZEROS. See Details.
   picture nozeros
              low   -     -1  =  '00.00' (prefix='-'          )
               -1  <-<     0  =     '99' (prefix='-.' mult=100)
                0   -<     1  =     '99' (prefix='.'  mult=100)
                1   -   high  =  '00.00';
run;
Add the PROCLIB.FORMATS catalog to the search path that SAS uses to find user-defined formats. The FMTSEARCH= system option defines the search path. The FMTSEARCH= system option requires only a libref. FMTSEARCH= assumes that the catalog name is FORMATS if no catalog name appears. Without the FMTSEARCH= option, SAS would not find the NOZEROS. format. For more information, see FMTSEARCH= System Option in SAS System Options: Reference.
options  fmtsearch=(proclib);
Print the SAMPLE data set. The FORMAT statement associates the NOZEROS. format with the Amount variable.
proc print data=sample;
   format amount nozeros.;
Specify the titles.
   title1 'Retrieving the NOZEROS. Format from PROCLIB.FORMATS';
   title2 'The SAMPLE Data Set';
run;

Output

Retrieving the NOZEROS. Format from PROCLIB.FORMATS
Retrieving the NOZEROS. Format from PROCLIB.FORMATS