BookmarkSubscribeSubscribe to RSS Feed

Community Trekker


Feb 28, 2017

List of Missing Values

I am writing a script that determines positional information using lists. It repeats several times for different groups of data, but some of the groups do not contain what I am looking for. This results in a list of missing values {., ., ., ., ., .}. 


When there are values in the list, I use List[Loc Nonmissing(List)] to get only the nonmissing values from my list and then N Items to count how many nonmissing values my list contains. However, when the list has only empty values, Loc Nonmissing returns [](0,1) which gives an error because it is used as a subscript. 


I can't figure out a way to deal with these lists full of missing values. Does anyone have any ideas???



Nov 21, 2014

Re: List of Missing Values

Maybe try using a "Try()".  This will prevent the error and you can add an argument in the Try() statement to just assign a value of zero to any variable that might contain the N Items command.  




Super User


Jun 22, 2012

Re: List of Missing Values

Another method that I have used in such cases, is to use the Sum() function.  It will work for both lists and scaler values, and will return a missing value when all elements of the list are missing.


Community Manager


Jun 23, 2011

Re: List of Missing Values

The [](0,1) indicates that it returned a matrix with 0 rows and 1 column.


So, you can use the NRow() function to see if it has 0 rows and act accordingly.


x={., ., ., ., ., .};

y=loc nonmissing(x);