Chapter Contents |
Previous |
Next |
The FORMAT Procedure |
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 |
Options |
DEFAULT=length | |
FUZZ= fuzz-factor | |
MAX=length | |
MIN=length | |
NOTSORTED |
In addition, you can use the following options:
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-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 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. |
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. |
Consider the following examples:
value $state 'Delaware'='DE' 'Florida'='FL' 'Ohio'='OH';
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.
yes
and
no
:
value answer 1='yes' 2='no';
Specifying No Ranges |
value format-name;
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.