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

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!

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.

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