BookmarkSubscribeRSS Feed
Chikku
Calcite | Level 5

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

3 REPLIES 3
data_null__
Jade | Level 19

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

art297
Opal | Level 21

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%

;

Peter_C
Rhodochrosite | Level 12

Before the input statement use

INFILE CARDS  TRUNCOVER ;

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1470 views
  • 0 likes
  • 4 in conversation