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

## Delete empty rows from a dataset

Hi All,

Is there any way to delete a row if all the coulmns in the row has empty values.

Thanks in advance.
1 ACCEPTED SOLUTION

Accepted Solutions
Quartz | Level 8

## Re: Delete empty rows from a dataset

Hi,
Had read this somewhere.
It should help you...

data work.test;
infile cards missover;
input (a b c) (\$1.) x y z;
if missing(coalesceC(of _character_)) and missing(coalesce(of
_numeric_)) then delete;
cards;
abc 1 2 3

def 3 4 5
;;;;
run;
proc print;
run;
7 REPLIES 7
Quartz | Level 8

## Re: Delete empty rows from a dataset

Hi,
Had read this somewhere.
It should help you...

data work.test;
infile cards missover;
input (a b c) (\$1.) x y z;
if missing(coalesceC(of _character_)) and missing(coalesce(of
_numeric_)) then delete;
cards;
abc 1 2 3

def 3 4 5
;;;;
run;
proc print;
run;
Calcite | Level 5

## Re: Delete empty rows from a dataset

Thanks NN that helped me a lot..
Rhodochrosite | Level 12

## Re: Delete empty rows from a dataset

if nmiss( of _numeric_ ) or cats( of _character_ ) =' ' then delete ;

this looks likely to do what is needed,
If there were not enough space in the default holder for cats() results, then you you are certainly not "missing", even if you get a warning.
Super User

## Re: Delete empty rows from a dataset

[pre]

data work.test;
infile cards missover;
input (a b c) (\$1.) x y z;
cards;
abc 1 2 3

def 3 4 5
;;;;
run;

options missing=' ';
data want;
set test;
if missing(cats(of _all_)) then delete;
run;
[/pre]

Ksharp
Calcite | Level 5

## Re: Delete empty rows from a dataset

this code is not removing the empty rows
Super User

## Re: Delete empty rows from a dataset

Are you run my code?
I test it ,it is successful under SAS9.2.
The dataset want has no missing row.

Ksharp
Super User

## Re: Delete empty rows from a dataset

Or Under Patrick's suggestion.

[pre]

data work.test;
infile cards missover;
input (a b c) (\$1.) x y z;
cards;
abc 2 2 3

def 3 4 5

abc 2 2 3
abc 2 2 3
;;;;
run;
%let dsid=%sysfunc(open(test));
%let nvar=%sysfunc(attrn(&dsid,nvar));
%let dsid=%sysfunc(close(&dsid));
data want;
set test;
if cmiss(of _all_) ge &nvar then delete;
run;
[/pre]

Ksharp
Discussion stats
• 7 replies
• 22053 views
• 1 like
• 5 in conversation