Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SAS - What is a good way to check if any of the variables in a list is missing

Tags:

sas

I have datasets where I sometimes need to select observations where none of the variables in the list are missing.

i.e I have to do this.

Where E1 NE . and E2 NE . and E3 NE .

or I can do it little bit more easily like this:

Where E1+E2+E3 NE .

But is there any way in SAS to do something like:

Where not missing(E1 - E3)

It doesn't work if I do

where sum(of E1-E3) NE .

Because that is equivalent to

Where E1 NE . or E2 NE . or E3 NE .

But i need "and" instead of "or".


I could also loop over those variables in a dataset and build a variable for the selection like:

array E E1-E3;
misind = 0;
do i=1 to dim(E);
    if E(i) = . then misind = 1;
end;

But that's not so simple either!

like image 651
Pekka Avatar asked Dec 04 '14 13:12

Pekka


Video Answer


1 Answers

I think you may use function nmiss or cmiss to check the exact number of columns with missing values.

for numerical columns. No column in e1-e3 is missing.

if nmiss(of e1-e3) = 0

for numerical/char mixed columns. No column in e1-e3 is missing.

if cmiss(of e1-e3) = 0
like image 165
Robbie Liu Avatar answered Sep 22 '22 15:09

Robbie Liu