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 multiple values for a given range or for overlapping ranges. The first value for a range is the primary value, and it is the only value used by most applications. The secondary values are used by certain applications that are designed to handle multilabel formats. Other applications ignore the secondary values. The following VALUE statements show the two uses of the MULTILABEL option:

proc format;
   value abc (multilabel) 1='ONE' 
                          1='UNO' 
                          1='UN';

   value overlap (multilabel) 

      /*standard demographic groups */
      0-17='demo1' 18-34='demo2' 
      35-49='demo3' 50-64='demo4'

      /* educational groups */
      0-5='preschool' 6-12='elem school' 
      13-15='jr high' 16-18='sr high' 
      19-22='college' 23-27='grad school'

      /* pure age groups */
      0-12='pre-teen' 13-19='teens' 
      20-29='twenties' 30-39='thirties' 
      40-49='forties' 50-high='over 50';
In the first VALUE statement, the value 1 can be formatted as ONE, UNO, or UN. The primary format is ONE, but secondary formats can be used by some applications. In the second VALUE statement, the primary format for 18 is 'demo2', but secondary formats can make 18 appear as 'sr high' or 'teens'.

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.