SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Reading Free-Format Data
Modifying List Input


Reading Nonstandard Values

The colon (:) modifier enables you to read nonstandard data values and character values longer than eight characters, but without 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 determines the variable's length, overriding the default length.

Notice the values representing the 1986 population of each city in the raw data file below. Because they contain commas, these values are nonstandard numeric values.


Raw Data File Topten
1---+----10---+----20---+--
 1 NEW YORK  7,262,700 
 2 LOS ANGELES  3,259,340 
 3 CHICAGO  3,009,530 
 4 HOUSTON  1,728,910 
 5 PHILADELPHIA  1,642,900 
 6 DETROIT  1,086,220 
 7 SAN DIEGO  1,015,190 
 8 DALLAS  1,003,520 
 9 SAN ANTONIO  914,350 
10 PHOENIX  894,070 


In order to read these values, you can modify list input with the colon (:) modifier followed by the COMMAw.d informat, as shown in the program below. Notice the COMMAw.d informat does not specify a w value.

     data perm.cityrank;
        infile topten;
        input Rank City & $12.
              Pop86 : comma.;

Remember that list input reads values until the next blank is detected. The default length of numeric variables is 8 bytes, so you don't need to specify a w value to determine 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 determine the number of columns to be read.


back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement