![]() 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 |
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:
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-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 |
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.