I am a (very) new SAS user who is working on a class project. I am graded for the number of observations in my 'output data' matching the number of observations in the raw data file. The raw data file has 1,242 observations, but when I run this code (see below) it gives me 1,238 observations. What would be possible reasons for this discrepancy, and how can I fix it?
Text files have LINES. Datasets have OBSERVATIONS.
So do the 1,242 lines include the header line you are skipping with the FIRSTOBS= option. If so you should expect 1,241 observations in the dataset.
There are a few things that can cause your code to create fewer observations than lines of text read.
One definite issue is that you are reading the first 10 bytes into tract_fips which might be a problem if any of the lines have fewer than 10 bytes on them.
You also did not include the TRUNCOVER option on your INFILE statement. That will prevent SAS from going to the next line to find a value when the current line does not have enough values to satisfy the INPUT statement.
Another possibility is that the actual lines are not delimited with the ampersand character, but actually are delimited with something else.
Text files have LINES. Datasets have OBSERVATIONS.
So do the 1,242 lines include the header line you are skipping with the FIRSTOBS= option. If so you should expect 1,241 observations in the dataset.
There are a few things that can cause your code to create fewer observations than lines of text read.
One definite issue is that you are reading the first 10 bytes into tract_fips which might be a problem if any of the lines have fewer than 10 bytes on them.
You also did not include the TRUNCOVER option on your INFILE statement. That will prevent SAS from going to the next line to find a value when the current line does not have enough values to satisfy the INPUT statement.
Another possibility is that the actual lines are not delimited with the ampersand character, but actually are delimited with something else.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.