Previous Page | Next Page

The FORMAT Procedure

VALUE Statement

Creates a format that specifies character strings to use to print variable values.
See also: The section about formats in SAS Language Reference: Dictionary for documentation about SAS formats.
Featured in: Creating a Format for Character Values.

VALUE <$>name <(format-option(s))>

Task Option
Specify the default length of the format. DEFAULT=
Specify a fuzz factor for matching values to a range. FUZZ=
Specify a maximum length for the format. MAX=
Specify a minimum length for the format. MIN=
Specify multiple values for a given range, or for overlapping ranges. MULTILABEL
Store values or ranges in the order that you define them. NOTSORTED

Required Arguments


names the format that you are creating.

Restriction: The name of a user-defined format cannot be the same as the name of a format that is supplied by SAS.
Requirement: The name must be a valid SAS name. A numeric format name can be up to 32 characters in length. A character format name can be up to 31 characters in length. If you are creating a character format, then use a dollar sign ($) as the first character.
Restriction: Format names cannot end in a number.
Interaction: The maximum length of a format name is controlled by the VALIDFMTNAME= SAS system option. See SAS Language Reference: Dictionary for details about VALIDFMTNAME=.
Tip: Refer to the format later by using the name followed by a period. However, do not use a period after the format name in the VALUE statement.


The following options are common to the INVALUE, PICTURE, and VALUE statements and are described in Informat and Format Options:


FUZZ= fuzz-factor




In addition, you can use the following options:


allows the assignment of multiple labels or external values to internal values. The following VALUE statements show the two uses of the MULTILABEL option. The first VALUE statement assigns multiple labels to a single internal value. Multiple labels can also be assigned to a single range of internal values. The second VALUE statement assigns labels to overlapping ranges of internal values. The MULTILABEL option allows the assignment of multiple labels to the overlapped internal values.

value one (multilabel)

value agefmt (multilabel)
   15-29='below 30 years'
   30-50='between 30 and 50'
   51-high='over 50 years'
   15-19='15 to 19'
   20-25='20 to 25'
   25-39='25 to 39'
   40-55='40 to 55'
   56-high='56 and above';
Only multilabel-enabled procedures such as PROC MEANS, PROC SUMMARY, and PROC TABULATE can use multiple labels. All other procedures and the data step recognize only the primary label. The primary label for a given entry is the external value that is assigned to the first internal value or range of internal values that matches or contains the entry when all internal values are ordered sequentially. For example, in the first VALUE statement, the primary label for 1 is ONE because ONE is the first external value that is assigned to 1. The secondary labels for 1 are UNO and UN. In the second VALUE statement, the primary label for 33 is 25 to 39 because the range 25-39 is sequentially the first range of internal values that contains 33. The secondary label for 33 is between 30 and 50 because the range 30-50 occurs in sequence after the range 25-39.

specifies one or more variable values and a character string or an existing format. The value-range-set(s) can be one or more of the following:

value-or-range-1 <..., value-or-range-n>='formatted-value'|[existing-format]

The variable values on the left side of the equal sign print as the character string on the right side of the equal sign.


specifies a character string that becomes the printed value of the variable value that appears on the left side of the equal sign. Formatted values are always character strings, regardless of whether you are creating a character or numeric format.

Formatted values can be up to 32,767 characters. For hexadecimal literals, you can use up to 32,767 typed characters, or up to 16,382 represented characters at 2 hexadecimal characters per represented character. Some procedures, however, use only the first 8 or 16 characters of a formatted value.

Requirement: You must enclose a formatted value in single or double quotation marks. The following example shows a formatted value that is enclosed in double quotation marks.
value $ score
   M=Male "(pass)"
   F=Female "(pass)";
Requirement: If a formatted value contains a single quotation mark, then enclose the value in double quotation marks:
value sect 1="Smith's class"
           2="Leung's class";
Tip: Formatting numeric variables does not preclude the use of those variables in arithmetic operations. SAS uses stored values for arithmetic operations.

specifies a format supplied by SAS or an existing user-defined format. The format you are creating uses the existing format to convert the raw data that match value-or-range on the left side of the equal sign.

If you use an existing format, then enclose the format name in square brackets (for example, [date9.]) or with parentheses and vertical bars, for example, (|date9.|). Do not enclose the name of the existing format in single quotation marks.

Using an existing format can be thought of as nesting formats. A nested level of one means that if you are creating the format A with the format B as a formatted value, then the procedure has to use only one existing format to create A.

Tip: Avoid nesting formats more than one level. The resource requirements can increase dramatically with each additional level.

For details on how to specify value-or-range, see Specifying Values or Ranges.

Consider the following examples:

  • The $STATE. character format prints the postal code for selected states:

    value $state 'Delaware'='DE'

    The variable value Delaware prints as DE, the variable value Florida prints as FL, and the variable value Ohio prints as OH. Note that the $STATE. format begins with a dollar sign.

    Note:   Range specifications are case sensitive. In the $STATE. format above, the value OHIO would not match any of the specified ranges. If you are not certain what case the data values are in, then one solution is to use the UPCASE function on the data values and specify all uppercase characters for the ranges.  [cautionend]

  • The numeric format ANSWER.writes the values 1 and 2 as yes and no:

    value answer 1='yes'

Specifying No Ranges

This VALUE statement creates a format-name format that has no ranges:

value format-name;

Using this format has the effect of applying the default SAS format to the values.

Previous Page | Next Page | Top of Page