SAS user-defined formats are stored independently from data sets. When creating a user-defined format, PROC FORMAT creates a format catalog named Formats in the Work library if one does not already exist. Otherwise, it updates the existing catalog. You can use the LIBRARY= (or LIB=) option to instruct PROC FORMAT to write the format to a permanent location.
Unlike elsewhere in SAS where the one-level name indicates a file in the Work library, a one-level name in the LIB= option indicates a library where you want to store the formats.
For example, in the below code, SAS will create a catalog named Formats in the directory defined as Library. The entry is named TESTFMT.
libname library 'c:\mySAS';
proc format lib=library;
value testfmt 1='yes'
2='no';
run;
How does SAS find formats?
SAS looks in the following locations for a catalog named Formats:
The Work and Library librefs are always searched first unless they appear in the FMTSEARCH= system option. If Work and Library appear in the list, these locations will be searched in the order in which they are listed. Note that the FMTSEARCH= system option expects a libref, not a path. For example:
options fmtsearch=(test);
The catalog does not have to be named Formats. You can use the PROC FORMAT LIB= option to specify a two-level name, where the first level is the libref and the second level is the name of the format catalog. The code below creates the catalog Cat in the directory defined by the Test libref:
libname test 'c:\mySAS';
proc format lib=test.cat;
When you create a catalog named anything other than Formats, you will also need to specify a two-level name in the FMTSEARCH= option:
options fmtsearch=(test.cat);
In the sample code above, we have instructed SAS to look for formats in the catalog Cat in the Test library.