Help using Base SAS procedures

better way to delete empty rows

Accepted Solution Solved
Reply
Contributor
Posts: 35
Accepted Solution

better way to delete empty rows

How to delete rows with missing values in every column?

Is there any simple way?

Thanks


Accepted Solutions
Solution
‎03-29-2012 11:15 AM
Respected Advisor
Posts: 3,124

better way to delete empty rows

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


All Replies
Solution
‎03-29-2012 11:15 AM
Respected Advisor
Posts: 3,124

better way to delete empty rows

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

Respected Advisor
Posts: 3,124

Re: better way to delete empty rows

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;

Contributor
Posts: 35

better way to delete empty rows

CMISS not support SAS 9.1.3

Respected Advisor
Posts: 3,124

better way to delete empty rows

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

Super User
Posts: 9,682

better way to delete empty rows

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

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 3792 views
  • 9 likes
  • 3 in conversation