user2886760
user2886760

Reputation: 31

Data input in SAS

Consider the follow test data set with 2 variables a and b:

data test;
infile 'C:\Users\Public\test.dat';
input a b;
run;

proc print data=test;
run;

When I run this code, I get the desired data set. However, when I add more variables, I get more numbers. Where do these numbers come from?

data test;
infile 'C:\Users\Public\test.dat';
input a b c d;
run;

proc print data=test;
run;

Upvotes: 0

Views: 177

Answers (1)

Joe
Joe

Reputation: 63424

What you're (presumably) seeing is the effect of FLOWOVER, the default SAS modifier to input from files or datalines (an option on the infile statement, or the filename statement).

When SAS reaches the end of a line, ie, reads the EOL character, but has further input needed, there are a few things it can do.

  • It can go to the next line to get more input
  • It can stop reading in and set the current variable to missing, and all further variables
  • It can stop reading in and keep the available input for the current variable, and set all other variables missing
  • It can stop reading in, throw an error, and return control to the user.

These are the FLOWOVER, MISSOVER, TRUNCOVER, and STOPOVER options. FLOWOVER is default, largely because way-back-when, it was common to have data on multiple lines as you had line length limitations (80 columns for card-column back when punch cards were in use), and SAS hates to break compatibility.

So what you're probably seeing between the first and second sets of code, is in the first set, you see (say) 100 lines x 2 columns. In the second you see 50 lines x 4 columns, with the even numbered columns from the first file being the 3rd and 4th columns in the new file.

Upvotes: 2

Related Questions