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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 761 views
  • 0 likes
  • 4 in conversation