Subscribe Bookmark RSS Feed

Select rows included in a list

teresa

Community Trekker

Joined:

Jun 23, 2011

I have a list like VAR={"P1", "P3", ...}
My Data Table have a column ("Variable") whose content are P1 or P2 or P3 or ...

example:
Row Variable Response
1 P1 3
2 P2 5
3 P3 7

I would like to say JMP to select rows whose :Variable's value are include in the list VAR. In my example I would like to select rows 1 and 3 because their values match with one of the values of the list.


Can anyone help me?

Thanks,

Teresa
3 REPLIES
mattf

Community Trekker

Joined:

Jun 23, 2011

//Here's one way that I think does what you want


dt = Open("$SAMPLE_DATA/Big Class.jmp");

// list of desired ages
myAgeList = List( 14, 15 );

// is the row a match for out list?
// row 3, (Jane) is 12, so no
Loc(myAgeList, :age[3])==[] ; // []=no

// row 17, (Elizabeth) is 14, so yes
y = Loc(myAgeList, :age[17]); // 1=yes 1st item in the list

// selectively select & color them
For Each Row(
If(Loc(myAgeList, :age)>=1,
ColorOf(Row state(i)) = 3; // change color to red for row i
Selected(Row State(i)) = 1; // select the desired rows
)
);


// Best regards,
// Matt
mattf

Community Trekker

Joined:

Jun 23, 2011

// Oops, forgot the iterator

For(i=1, i<=n Rows(dt), i++,
If(Loc(myAgeList, :age)>=1,
ColorOf(Row state(i)) = 3; // change color to red for row i
Selected(Row State(i)) = 1; // select the desired rows
)
);
teresa

Community Trekker

Joined:

Jun 23, 2011

Thanks Matt,

You have give me a good solution.

Following your idea, I have tried with this:

for each row (if(contains(VARS,:Lineas)>0, Row State()=selected state(1) ));

(VARS is the list and :Lineas de Column I would like to compare)

It seems it works, and I do not need to use the iterator.

Best regards,

Teresa