Chapter Contents

Previous

Next
The FORMAT Procedure

Specifying Values or Ranges

As the syntax of the INVALUE, PICTURE, and VALUE statements indicates, you must specify values as value-range-sets. On the left side of the equals sign you specify the values that you want to convert to other values. On the right side of the equals sign, you specify the values that you want the values on the left side to become. This section discusses the different forms you can use for value-or-range, which represents the values on the left side of the equals sign. For details on how to specify values for the right side of the equals sign, see "Required Arguments" for the appropriate statement.

The INVALUE, PICTURE, and VALUE statements accept numeric values on the left side of the equals sign. INVALUE and VALUE also accept character strings on the left side of the equals sign.

As the syntax shows, you can have multiple occurrences of value-or-range in each value-range-set, with commas separating the occurrences. Each occurrence of value-or-range is either one of the following:

value
a single value, for example, 12 or'CA'. Enclose character values in single quotation marks; if you omit the quotes around value, PROC FORMAT assumes the quotes to be there.

You can use the keyword OTHER as a single value. OTHER matches all values that do not match any other value or range.

range
a list of values, for example, 12-68 or 'A'-'Z'. For ranges with character strings, be sure to enclose each string in single quotation marks. For example, if you want a range that includes character strings from A to Z, specify the range as 'A'-'Z', with single quotes around the A and around the Z.

If you specify 'A-Z', the procedure interprets it as a three-character string with A as the first character, a hyphen (-) as the second character, and a Z as the third character.

If you omit the quotes, the procedure assumes quotes around each string. For example, if you specify the range abc-zzz, the procedure interprets it as 'abc'-'zzz'.

You can use LOW or HIGH as one value in a range, and you can use the range LOW-HIGH to encompass all values. For example, these are valid ranges:

low-'ZZ'
35-high
low-high

You can use the less than (<) symbol to exclude values from ranges. If you are excluding the first value in a range, put the < after the value. If you are excluding the last value in a range, put the < before the value. For example, the following range does not include 0:

   0<-100

Likewise, the following range does not include 100:

   0-<100

The following ranges show how to avoid overlapping ranges using noninclusive notation:

   'AA'-<'AJ'=1 'AJ'-'AZ'=2

AJ is part of the second range, not the first.

If you overlap values in ranges, PROC FORMAT assigns the value to the first range. For example, in the following ranges, the value AJ is part of the first range:

'AA'-'AJ'=1 'AJ'-'AZ'=2

Each value-or-range can be up to 200 characters. If value-or-range has more than 200 characters, the procedure truncates the value after it processes the first 200 characters.

Note:   You do not have to account for every value on the left side of the equals sign. Those values are converted using the default informat or format. For example, the following VALUE statement creates the TEMP. format, which prints all occurrences of 98.6 as NORMAL:

value temp 98.6='NORMAL';
If the value were 96.9, the printed result would be 96.9.  [cautionend]


Chapter Contents

Previous

Next

Top of Page

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