DATA Step, Macro, Functions and more

How to read records with missing data

Reply
Contributor
Posts: 29

How to read records with missing data

in the below prog,how can i enforce SAS to read the second line/record containing the missing data for A2,A4?which option is best to use(missover/truncover/flowover/deleteover)

data temp;

input A1 A2 A3 $ A4 mmddyy10. a5 percent6.;

cards;

1 3 retd 12/12/2009 56.32%

2 tujb 54.32%

;

run;

proc print data=temp;

run; i

Respected Advisor
Posts: 3,777

Re: How to read records with missing data

What is the attribute of record 2 that tells you that A2 and A4 are missing?

PROC Star
Posts: 7,364

Re: How to read records with missing data

If you will only be missing columns 2,4 and/or 5 the following might work:

data temp (drop=x dummy);

  infile cards truncover;

  informat a1 a2 12.;

  informat a3 $8.;

  informat a4 mmddyy10.;

  format a4 mmddyy10.;

  informat a5 percent6.;

  x=0;

  input a1 a2 @;

  if missing(a2) then do;

    input @1 dummy a3 a4 @;

    x+1;

  end;

  else do;

    input a3 a4 @;

  end;

  if missing(a4) then x+1;

  if x gt 0 then do;

    input @1 dummy @;

    do _n_=2 to x;

      input dummy @;

    end;

  end;

  input a5;

cards;

1 3 retd 12/12/2009 56.32%

2 tujb 54.32%

;

Valued Guide
Posts: 2,175

Re: How to read records with missing data

Before the input statement use

INFILE CARDS  TRUNCOVER ;

Ask a Question
Discussion stats
  • 3 replies
  • 212 views
  • 0 likes
  • 4 in conversation