Summary

Text Summary

Creating Custom Formats Using the VALUE Statement

Character and numeric formats are created by using VALUE statements in a FORMAT procedure. When you specify a libref in the LIBRARY= option, the format is stored in the specified library. If no catalog name is specified, the format is saved in the Formats catalog by default.

Creating Formats with Overlapping Ranges

Use the MULTILABEL option to create a format that has overlapping ranges. When a format has overlapping ranges, the values in the format might have more than one label. This format can be used in procedures that support the MLF option.

Creating Custom Formats Using the PICTURE Statement

The PICTURE statement is used to create a template for formatting values of numeric variables. Pictures are specified using digit selectors, message characters, and directives.

Documenting Formats

Use the FMTLIB keyword in the PROC FORMAT statement to get documentation about the formats in the specified catalog. The output displays the format name, start and end values, and the label. You can also use the SELECT and EXCLUDE statements to process specific formats rather than an entire catalog.

Managing Formats

Because formats are saved as catalog entries, you use PROC CATALOG to copy, rename, delete, or create a listing of the entries in a catalog.

Using Custom Formats

Once you have created a format, you can reference it as you would reference a SAS format. If you have stored the format in a location other than Work.Formats, you must use the FMTSEARCH= system option to add the location to the search path so that SAS can locate the format. It can be useful to change the default FMTERR system option to NOFMTERR. Changing the default system option enables SAS to substitute the w. or $w. format and continue processing if SAS does not find a format you reference.
You can permanently associate a format with a variable by modifying the data set using PROC DATASETS.

Creating Formats from SAS Data Sets

Use the CNTLIN= option to specify a SAS data set that you want to use to create a format. The SAS data set must contain the variables FmtName, Start, and Label. If the values have ranges, there must also be an End variable.

Creating SAS Data Sets from Formats

Use the CNTLOUT= option to create a SAS data set from a format. This is useful for maintaining formats because you can easily update a SAS data set.

Sample Programs

Creating a Multilabel Format

proc format;
   value dates (multilabel)
         '01jan2000'd - '31mar2000'd = '1st Quarter'
         '01apr2000'd - '30jun2000'd = '2nd Quarter'
         '01jul2000'd - '30sep2000'd = '3rd Quarter'
         '01oct2000'd - '31dec2000'd = '4th Quarter'
         '01jan2000'd - '30jun2000'd = 'First Half of Year'
         '01jul2000'd - '31dec2000'd = 'Second Half of Year';
run;

Creating a Picture Format

proc format;
   picture rainamt
           0-2='9.99 slight'
           2<-4='9.99 moderate'
           4<-<10='9.99 heavy'
           other='999 check value';
run;

Creating a Picture Format Using Directives

proc format;
   picture mydate
           low-high='%0d-%b%Y  ' (datatype=date);
run;

Restructuring a SAS Data Set and Creating a Format from the Data

data sasuser.aports;
   keep Start Label FmtName;
   retain FmtName '$airport';
   set sasuser.acities (rename=(Code=Start
       City= Label));
run;

proc format library=sasuser cntlin=sasuser.aports;
run;

Creating a SAS Data Set from a Format

proc format lib=sasuser cntlout=sasuser.fmtdata;
   select $airport;
run;

Points to Remember

  • By default, SAS searches for formats in the Work.Formats and Library.Formats catalogs. If you store formats in other catalogs, you must use the FMTSEARCH= system option to tell SAS where to look for your formats.
  • You can use the CNTLIN= option to create a format from a SAS data set, but the data set must contain the following variables:
    • FmtName, Start, and Label
    • Type for character formats, unless the value for FmtName begins with a $
    • End if a range is specified
..................Content has been hidden....................

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