Subscribe Bookmark RSS Feed

Effective method to test matrix columns

uday_guntupalli

Community Trekker

Joined:

Sep 15, 2014

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

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

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
Solution

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
uday_guntupalli

Community Trekker

Joined:

Sep 15, 2014

Hello Michael ,

       How does that replace the selected data with NULLS ?

Uday

michael_jmp

Staff

Joined:

Jun 23, 2011

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