Community Trekker

Joined:

Jun 23, 2011

How to determine if any list element has missing data

Does anyone know the easiest way in JSL to determine if a list (e.g. numbers) contains at least 1 element who's data is missing?  In this case it might set another variable to False (meaning the list does contain at least 1 element with missing data, else if True all elements contain non-missing data).

thx.. dj

2 REPLIES

Community Trekker

Joined:

Jun 23, 2011

Re: How to determine if any list element has missing data

Hi:

Perhaps:

list1 = {1,2,3,4};

list2 = {1,2,.,4};

n1 = if(N Missing(list1)>0,"True","False");

n2 = if(N Missing(list2)>0,"True","False");

Best regards,

-Matt

Super User

Joined:

Jun 23, 2011

Re: How to determine if any list element has missing data

Another variation is to use the LOC function to find all missing values.  I use this when I want to replace missing values with 0, for example:

a = {1, 2, 3, 4, ., 5, 6, .};

b = loc(a, .);

This will return the matrix [5, 8].  You could determine if any list elements are missing by checking for

nrows(b) > 0;