I am having trouble getting Column Stats to work in a loop?
I am trying to write a script it remove outliers from multiple columns in a table by using a loop to look at each column name and pass this into a function which has the following line of code to work out the 99th percentile.
test_upper_quantile=Col Quantile( Column( Test_Number ), 0.99 );
I then use a For Each Row loop to compare the values against the calculated percentile and remove any Rows which fall outside this.
The code works fine if I only do one column however if I set the loop up with multiple columns reading the column names into the Test_Number variable, jmp always uses the value of the quantile first calculated for the first column, it doesnt recalculate for each column. The loop looks to be set up correctly as it displays the variable Test_Number in the log and this changes to match the column as expected. So if I do 10 columns I get the 10 correct column names displayed but only the quantile from the first column repeated 10 times!!!
Also when the script finishes if I highlight the line of code below, it calculates the value for the last column it encountered correctly.
test_upper_quantile=Col Quantile( Column( Test_Number ), 0.99 );
I have tried clearing the global test_upper_quantile which holds the quantile value at the begining of the function but this makes no difference?
Any ideas? I did notice when you hover the cursor over the column quantile comand it says it gets cached. Is this my problem if so is there a way to clear the cache?
The complete function is shown
remove_outliers = Function( {Test_Number},
show(test_number);
test_lower_quantile = Col Quantile( Column( Test_Number ), 0.01 );
test_upper_quantile = Col Quantile( Column( Test_Number ), 0.99 );
show(test_upper_quantile);
lower_cutoff = test_lower_quantile;
upper_cutoff = test_upper_quantile;
For Each Row(
If( Column( test_number )[] < lower_cutoff,
Excluded( Row State() ) = 1
);
If( Column( test_number )[] > upper_cutoff,
Excluded( Row State() ) = 1
);
);
);
Message was edited by: apeden