BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kishore415
Calcite | Level 5
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
NN
Quartz | Level 8 NN
Quartz | Level 8
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;

View solution in original post

7 REPLIES 7
NN
Quartz | Level 8 NN
Quartz | Level 8
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;
kishore415
Calcite | Level 5
Thanks NN that helped me a lot..
Peter_C
Rhodochrosite | Level 12
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.
Ksharp
Super User
[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
Ankitsas
Calcite | Level 5
this code is not removing the empty rows
Ksharp
Super User
Are you run my code?
I test it ,it is successful under SAS9.2.
The dataset want has no missing row.


Ksharp
Ksharp
Super User
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

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
  • 7 replies
  • 21908 views
  • 1 like
  • 5 in conversation