Chapter Contents

Previous

Next
The FORMAT Procedure

VALUE Statement


Creates a format that specifies character strings to use to print variable values.

Featured in: Creating a Format for Character Values .
See also: The chapter on formats in SAS Language Reference: Dictionary for documentation on formats supplied by SAS.


VALUE <$>name <(format-option(s))>
<value-range-set(s)>;

To do this Use this 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

name
names the format you are creating. The name must be a SAS name up to eight characters long, not ending in a number. Character format names must have a dollar sign ($) as the first character and no more than seven additional characters. A user-defined format cannot be the name of a format supplied by SAS. Refer to the format later by using the name followed by a period. However, do not put a period after the format name in the VALUE statement.


Options
The following options are common to the INVALUE, PICTURE, and VALUE statements and are described in Informat and Format Options :
DEFAULT=length
FUZZ= fuzz-factor
MAX=length
MIN=length
NOTSORTED

In addition, you can use the following options:

MULTILABEL
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 may 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)
   1='ONE'
   1='UNO'
   1='UN'

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 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.

value-range-set(s)
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 equals sign print as the character string on the right side of the equals sign.

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

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

If you omit the single quotation marks around formatted-value, the VALUE statement assumes them to be there.

If a formatted value contains a single quotation mark, write it as two separate single quotation marks:

value sect 1='Smith''s class'
           2='Leung''s class';
Tip: Formatting numeric variables does not preclude your using those variables in arithmetic operations. SAS uses stored values for arithmetic operations.

existing-format
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 equals sign.

If you use an existing format, 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, the procedure only has to use one existing format to create A.
Tip: Avoid nesting formats more than one level. The resource requirements increase dramatically with each additional level.

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

Consider the following examples:


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

value format-name;


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.