Subscribe Bookmark RSS Feed

How to determine if any list element has missing data

djhanson

Community Trekker

Joined:

Jun 23, 2011

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
mattf

Community Trekker

Joined:

Jun 23, 2011

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

pmroz

Super User

Joined:

Jun 23, 2011

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;