BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
George_S
Fluorite | Level 6

How to delete rows with missing values in every column?

Is there any simple way?

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

You need to provide some samples. for one of the simplest senarios:

data have;

input a1-a4;

cards;

1 2 3 4

. . . .

5 6 7 8

;

data want;

set have;

if n(of a1-a4);

run;

proc print;run;

Regards,

Haikuo

View solution in original post

5 REPLIES 5
Haikuo
Onyx | Level 15

You need to provide some samples. for one of the simplest senarios:

data have;

input a1-a4;

cards;

1 2 3 4

. . . .

5 6 7 8

;

data want;

set have;

if n(of a1-a4);

run;

proc print;run;

Regards,

Haikuo

Haikuo
Onyx | Level 15

I know there are better solutions out there, but for a more general approach, this is what I came up:

data have;

input a1-a4;

cards;

1 2 3 4

. . . .

5 6 7 8

. 1 . .

;

proc sql;

select count(name) into :names from dictionary.coluMNs

where libname='WORK' AND MEMNAME='HAVE';

QUIT;

data want;

set have;

if CMISS(OF _ALL_)<&NAMES;

run;

proc print;run;

George_S
Fluorite | Level 6

CMISS not support SAS 9.1.3

Haikuo
Onyx | Level 15

In that case, there is an old fashion way hopefully to meet your need:

data have;

input a1-a4 (c1-c3) ($);

cards;

1 2 3 4    a b c

. . . .    . . .

5 6 7 8    . . f

. 1 . .    . . .

;

data want;

set have;

array c _character_;

if n(of _numeric_)=0 then

do over c;

   if not missing(c) then

     do;

     output;

     return;

     end;

end;

else output;

run;

proc print;run;

Regards,

Haikuo

Ksharp
Super User

OH. Hope you could have SAS 9.2 as fast as you can.

data have;
input name $ a1-a4;
cards;
q 1 2 . 4
. . . . .
w 5 6 7 8
;
run;
options missing=' ';
data want;
 set have;
 if missing(cats(of _all_)) then delete;
run;

Ksharp

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5 replies
  • 7257 views
  • 9 likes
  • 3 in conversation