Interview Question: Mark the Missing Ones

Sample Question #111 (programming – SAS)

Imagine we have a text data file with five fields in each record: ID, age, sex, zip code, and income. But for some records, the income field is blank (i.e., missing but not populated with anything to indicate it’s missing).  For example, the first four lines of the input file looks like:

323553 23 F 98630 50328.32
864970 32 M 02138 103458.09
732481 15 F 10013
124869 89 M 86704 2358.16

How do you read a file like this correctly in SAS, so that missing incomes are automatically denoted as "missing" by SAS?

Advertisements
This entry was posted in Sample Qs. Bookmark the permalink.

One Response to Interview Question: Mark the Missing Ones

  1. Brett says:

    ANSWER
     
    To avoid having SAS read in the next available number, "124869" (the next person’s ID), as the value for 732481’s income, we must use the MISSOVER option of the INFILE statement:
     
         infile ‘c:\data\income.dat’ missover;     input id age sex $ zip income;
     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s