mbrookz
mbrookz

Reputation: 35

How do I get multiple lines to display in SAS when there are missing values?

Data example;
   Input name $ number;
Cards;
John
Jane 2
;
Run;

I'm using this code but because I'm missing a value in the first line only the first line displays in the output. How do I get both lines to appear?

Upvotes: 0

Views: 287

Answers (1)

Tom
Tom

Reputation: 51566

The default behavior for the INPUT statement is to go to the next line if there are not enough values on the current line. This is called the FLOWEVER option on the INFILE statement.

You could make sure that each variable has a value in the line by using a period to mark the missing values. (This works for both numeric and character variables.)

data example;
  input name $ number;
cards;
John .
Jane 2
;

If each observation is all on one line (and the missing values are always those at the end of the line) then you could use the TRUNCOVER option of the INFILE statement to prevent the INPUT from hunting for more values on the next line. If the data is in-line with the code as in your example then just add an INFILE statement anyway and use CARDS (or DATALINES) as the fileref.

data example;
  infile cards truncover;
  input name $ number;
cards;
John 
Jane 2
;

Upvotes: 1

Related Questions