SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Reading Free-Format Data
Reading Missing Values


Reading Missing Values at the End of a Record

As you've learned, list input imposes some limitations on reading raw data that has missing values. Let's take a look at how to handle missing values at the end of a record.

Suppose that the third person represented in the raw data file below did not answer the questions about the number of department store cards and the frequency of use.


1---+----10---+----20
MALE 27 1 8 0 0  
FEMALE  3 14 5 10  
FEMALE 34 2 10     
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  


Because the missing values occur at the end of the record, you can use the MISSOVER option in the INFILE statement to read the missing values at the end of the record. The MISSOVER option prevents SAS from going to another record if, when using list input, it does not find values in the current line for all the INPUT statement variables. At the end of the current record, values that are expected but not found are set to missing.

Simply specify the MISSOVER option in the INFILE statement. The MISSOVER option prevents the fields in the fourth record from being read as values for Deptcard and FreqDept in the third observation. Note that Deptcard and FreqDept are set to missing.

     data perm.survey;
        infile credit missover;
        input Gender $ Age Bankcard FreqBank 
              Deptcard FreqDept;
     run;
     proc print data=perm.survey;
     run; 

Obs Gender Age Bankcard FreqBank Deptcard FreqDept
1 MALE 27 1 8 0

0

2 FEMALE 29 3 14 5

10

3 FEMALE 34 2 10

.

.

4 MALE 35 2 12 4

8

5 FEMALE 36 4 16 3

7

6 MALE 21 1 5 0

0


Alert The MISSOVER option only works for missing values that occur at the end of the record.


back||next


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

Terms of Use & Legal Information | Privacy Statement