Chapter 23: The FORMAT Procedure


Overview: FORMAT Procedure

What Does the FORMAT Procedure Do?

The FORMAT procedure enables you to define your own informats and formats for variables . In addition, you can print the parts of a catalog that contain informats or formats, store descriptions of informats or formats in a SAS data set, and use a SAS data set to create informats or formats.

What Are Formats and Informats?

Informats determine how raw data values are read and stored. Formats determine how variable values are printed. For simplicity, this section uses the terminology the informat converts and the format prints .

Informats and formats tell the SAS System the data s type (character or numeric) and form (such as how many bytes it occupies; decimal placement for numbers ; how to handle leading, trailing, or embedded blanks and zeros; and so forth). The SAS System provides informats and formats for reading and writing variables. For a thorough description of informats and formats that SAS provides, see the sections on formats and informats in SAS Language Reference: Dictionary .

With informats, you can

  • convert a number to a character string (for example, convert 1 to YES )

  • convert a character string to a different character string (for example, convert 'YES' to 'OUI' )

  • convert a character string to a number (for example, convert YES to 1)

  • convert a number to another number (for example, convert 0 through 9 to 1, 10 through 100 to 2, and so forth.

With formats, you can

  • print numeric values as character values (for example, print 1 as MALE and 2 as FEMALE )

  • print one character string as a different character string (for example, print YES as OUI )

  • print numeric values using a template (for example, print 9458763450 as 945-876-3450 ).

How Are Formats and Informats Associated with a Variable?

The following figure summarizes what occurs when you associate an informat and format with a variable. The COMMA w.d informat and the DOLLAR w.d format are provided by SAS.

click to expand
Display 23.1: Associating an Informat and a Format with a Variable

In the figure, SAS reads the raw data value that contains the dollar sign and comma. The COMMA9.2 informat ignores the dollar sign and comma and converts the value to 1544.32. The DOLLAR9.2 format prints the value, adding the dollar sign and comma. For more information about associating informats and formats with variables, see Associating Informats and Formats with Variables on page 455.




Base SAS 9.1.3 Procedures Guide (Vol. 1)
Base SAS 9.1 Procedures Guide, Volumes 1, 2, 3 and 4
ISBN: 1590472047
EAN: 2147483647
Year: 2004
Pages: 260

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net