Sunday, October 17, 2010

Difference between infile option MISSOVER and TRUNCOVER

Both will assign missing values to variables if the data line ends before the variable’s field starts. But when the data line ends in the middle of a variable field, TRUNCOVER will take as much as is there, whereas MISSOVER will assign the variable a missing value.

For example, here is the raw data infileoptions.txt stored in c:\myrawdata\
1
22
333
4444
55555

With option MISSOVER:

data new1;
    infile 'c:\myrawdata\infileoptions.txt' misscover;
    input id $3.;
run;

We will get the following dataset:

Obs    id
   1
   2
   3     333
   4     444
   5     555

With optionTRUNCOVER:

data new2;
   infile 'c:\myrawdata\infileoptions.txt' truncover;
   input id $3.;
run;

We will get the following dataset:

Obs    id
   1     1
   2     22
   3     333
   4     444
   5     555

Without options:

data new3;
   infile 'c:\myrawdata\infileoptions.txt';
   input id $3.;
run;

We will get the following dataset that may not be what you expect:

Obs    id
   1     22
   2     333
   3     444
   4     555
                                                 

1 comment:

  1. PLZ CAN EXPLAIN THESE TWO EXAMPLES BY TAKING BOT CHARACTER AND NUMERIC DTAT

    ReplyDelete