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 ;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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