SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Reading Free-Format Data
Using List Input


List input is a powerful tool for reading both standard and nonstandard free-format data.


General form, INPUT statement using list input:
INPUT variable <$>;

where

  • variable names the variable whose value the INPUT statement is to read
  • $ identifies the variable as a character variable.


Suppose you have an external data file like the one shown below. The file, referenced by the fileref Credit, contains the results of a survey on credit card use among males and females in the 18-39 age range.


Raw Data File Credit
1---+----10---+----20
MALE 27 1 8 0 0
FEMALE 29 3 14 5 10
FEMALE 34 2 10 3 3
MALE 35 2 12 4 8
FEMALE 36 4 16 3 7
MALE 21 1 5 0 0
MALE 25 2 9 2 1
FEMALE 21 1 4 2 6
MALE 38 3 11 4 3
FEMALE 30 3 5 1 0


You need to read the data values for
  • gender
  • age
  • number of bank cards
  • bank card use per month
  • number of department cards
  • department card use per month.

List input may be the easiest input style to use because, as shown in the INPUT statement below, you simply list the variable names in the same order as the corresponding raw data fields. Remember to distinguish character variables from numeric variables.

     input Gender $ Age Bankcard FreqBank Deptcard 
           FreqDept; 
Because list input, by default, does not specify column locations,
  • all fields must be separated by at least one blank or other delimiter
  • fields must be read in order from left to right
  • you cannot skip or reread fields.

back||next


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

Terms of Use & Legal Information | Privacy Statement