Managing Custom Formats

Using FMTLIB with PROC FORMAT to Document Formats

When you have created a large number of permanent formats, it can be easy to forget the exact spelling of a specific format name or its range of values. Remember that adding the keyword FMTLIB to the PROC FORMAT statement displays a list of all the formats in the specified catalog, along with descriptions of their values.
libname myfmts 'c:sas
ewfmt';
proc format lib=myfmts fmtlib;
run;
You can also use the SELECT and EXCLUDE statements to process specific formats rather than an entire catalog.
General form, PROC FORMAT with FMTLIB and the SELECT and EXCLUDE statements:
PROC FORMAT LIB=library FMTLIB;
SELECT format-name;
EXCLUDE format-name;
RUN;
Here is an explanation of the syntax:
library
is the name of the library where the formats are stored. If you do not specify the LIB= option, formats in the Work library are listed.
format-name
is the name of the format that you want to select or exclude.

Example

The following code displays only the documentation for the $ROUTES. format. Notice that you do not use a period at the end of the format name when you specify the format in the SELECT statement.
libname myfmts 'c:sas
ewfmt';
proc format lib=myfmts fmtlib;
   select $routes;
run;
Table 17.1 SAS Output
FORMAT NAME : $ROUTES LENGTH: 7 NUMBER OF VALUES: 5 MIN LENGTH: 1 MAX LENGTH: 40 DEFAULT LENGTH: 7 FUZZ: 0
START
END
LABEL (VER. V7|V8 29AUG2002:11:13:14)
Missing
Route1
Route1
Zone 1
Route2
Route4
Zone 2
Route5
Route7
Zone 3
**OTHER**
**OTHER**
Unknown
Tip
If you specify more than one format on the SELECT or EXCLUDE statement, separate each format name with a space as follows:
select $routes newdate;

Using PROC CATALOG to Manage Formats

Because formats are saved as catalog entries, you can use the CATALOG procedure to manage your formats. Using PROC CATALOG enables you to do the following:
  • create a listing of the contents of a catalog
  • copy a catalog or selected entries within a catalog
  • delete or rename entries within a catalog
General form, PROC CATALOG step:
PROC CATALOG CATALOG=libref.catalog;
CONTENTS <OUT=SAS-data-set>;
COPY OUT=libref.catalog <options>;
SELECT entry-name.entry-type(s);
EXCLUDE entry-name.entry-type(s);
DELETE entry-name.entry-type(s);
RUN;
QUIT;
Here is an explanation of the syntax:
libref.catalog
with the CATALOG= argument is the SAS catalog to be processed.
SAS-data-set
is the name of the data set that will contain the list of the catalog contents.
libref.catalog
with the OUT= argument is the SAS catalog to which the catalog entries will be copied.
entry-name.entry-type(s)
are the full names of catalog entries (in the form name.type) that you want to process.

Example

The first PROC CATALOG step below copies the $ROUTES. format from the Library.Formats catalog to the Work.Formats catalog. Notice that in the SELECT statement, you specify the $ROUTES. character format using the full catalog entry name, ROUTES.FORMATC.
proc catalog catalog=myfmts.formats;
   copy out=work.formats;
   select routes.formatc;
run;
proc catalog cat=work.formats;
   contents;
run;
quit;
The second PROC CATALOG step displays the contents of the Work.Formats catalog. A note is written to the log when the format is copied from one catalog to another.
Contents of Catalog WORK.FORMATS
Tip
For more information about PROC CATALOG, including other statements and options that you can use, see the SAS documentation.
..................Content has been hidden....................

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