The colon (:) modifier enables you
to read nonstandard data values and character values that are longer
than eight characters, but which contain no embedded blanks. The :
indicates that values are read until a blank (or other delimiter)
is encountered, and then an informat is applied. If an informat for
reading character values is specified, the w value
specifies the variable's length, overriding the default length.
Notice the values representing
the 2016 population of each city in the raw data file below. Because
they contain commas, these values are nonstandard numeric values.
In order to read these values,
you can modify list input with the colon (:) modifier, followed by
the COMMA
w.d informat, as shown
in the program below. Notice that the COMMA
w.d informat
does not specify a
w value.
data sasuser.cityrank;
infile topten;
input Rank City & $12.
Pop86 : comma.;
Remember that list input
reads each value until the next blank is detected. The default length
of numeric variables is 8, so you do not need to specify a w value
to indicate the length of a numeric variable.
This is different from
using a numeric informat with formatted input. In that case, you must
specify a w value in order
to indicate the number of columns to be read.