Choose Language Hide Translation Bar
Community Trekker

## Effective method to test matrix columns

Hello all ,

I have a matrix with 5 columns . I want to filter the matrices for a specific condition so lets say MinValue = 20 and the name of my matrix is Data .

How can I filter the values in each column using the MinValue and replace everything which fails the condition with NULL . How can I do it if I were to do it for the entire matrix and specifically for one or more columns ?

For Eg :

Col1  Col2  Col3  Col4  Col5

50      2       60    40      10

10      10     10    10       10

21      22     23    19       24

Output should be

Col1         Col2          Col3        Col4          Col5

50            NULL        60             40           NULL

NULL       NULL       NULL        NULL       NULL

21            22            23            NULL        24

I dont want to use loops if there is a possibility .

Regards

Uday

Best
Uday
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Staff

## Re: Effective method to test matrix columns

If I'm understanding your question correctly, the loc() function in JSL should help:

minValue = 20;

data = [

50 2 60 40 10,

10 10 10 10 10,

21 22 23 19 24];

data[loc(data<20)] = .;

show(data);

Michael Crotty
Sr Statistical Writer
JMP Development
3 REPLIES 3
Highlighted
Staff

## Re: Effective method to test matrix columns

If I'm understanding your question correctly, the loc() function in JSL should help:

minValue = 20;

data = [

50 2 60 40 10,

10 10 10 10 10,

21 22 23 19 24];

data[loc(data<20)] = .;

show(data);

Michael Crotty
Sr Statistical Writer
JMP Development
Community Trekker

## Re: Effective method to test matrix columns

Hello Michael ,

How does that replace the selected data with NULLS ?

Uday

Best
Uday
Staff

## Re: Effective method to test matrix columns

The loc() function is returning a vector of positions (locations) in the matrix where the value is less than 20. Then I am using the vector of positions as a subscript to the matrix and assigning a missing value (the period) to those positions in the matrix.

Michael Crotty
Sr Statistical Writer
JMP Development