A more flexible version of list
input, called modified list input, includes format modifiers. The
following format modifiers enable you to use list input to read nonstandard
data by using SAS informats:
-
The & (ampersand) format modifier
enables you to read character values that contains one or more embedded
blanks with list input and to specify a character informat. SAS reads
until it encounters two consecutive blanks, the defined length of
the variable, or the end of the input line, whichever comes first.
-
The : (colon) format modifier enables
you to use list input but also to specify an informat after a variable
name, whether character or numeric. SAS reads until it encounters
a blank column, the defined length of the variable (character only),
or the end of the data line, whichever comes first.
-
The ~ (tilde) format modifier enables
you to read and retain single quotation marks, double quotation marks,
and delimiters within character values.
The following is an
example of the : and ~ format modifiers. You must use the DSD option
in the INFILE statement. Otherwise, the INPUT statement ignores the
~ format modifier.
data scores;
infile datalines dsd;
input Name : $9. Score1-Score3 Team ~ $25. Div $;
datalines;
Smith,12,22,46,"Green Hornets, Atlanta",AAA
Mitchel,23,19,25,"High Volts, Portland",AAA
Jones,09,17,54,"Vulcans, Las Vegas",AA
;
proc print data=scores noobs;
run;
Output from Example with Format Modifiers
The SAS System 1
Name Score1 Score2 Score3 Team Div
Smith 12 22 46 "Green Hornets, Atlanta" AAA
Mitchel 23 19 25 "High Volts, Portland" AAA
Jones 9 17 54 "Vulcans, Las Vegas" AA