Factor Variable Characteristics in the Output Data Set

When you use the OUTPUT statement to save a design in a data set and you rename and recode a factor, the type and length of the new variable are determined by whether you use the NVALS= or CVALS= option. A factor variable whose values are coded with the NVALS= specification is of numeric type. A factor variable whose values are coded with the CVALS= option is of character type, and the length of the variable is set to the length of the longest character string; shorter strings are padded with trailing blanks.

For example, in the specifications

cvals=('String 1' 'A longer string')
cvals=('String 1' 'String 2')

the first value in the first CVALS= specification is padded with seven trailing blanks. One consequence is that it no longer matches the ‘String 1’ of the second specification. To match two such values (for example, when merging two designs), use the TRIM function in the DATA step (see SAS Language Reference: Dictionary for details).