cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-299%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E9%81%B8%E6%93%87%E5%88%97%E5%80%BC%E8%88%87%E4%BB%BB%E6%84%8F%E6%B8%85%E5%96%AE%E4%B8%AD%E7%9A%84%E9%A0%85%E7%9B%AE%E7%9B%B8%E7%AC%A6%E7%9A%84%E8%A1%8C%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-299%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E4%BD%A0%E5%A5%BD%EF%BC%8C%3CBR%20%2F%3E%3CBR%20%2F%3E%E6%88%91%E6%AD%A3%E5%9C%A8%E5%98%97%E8%A9%A6%E7%B7%A8%E5%AF%AB%E4%B8%80%E4%BA%9B%20JSL%20%E7%A8%8B%E5%BC%8F%E7%A2%BC%E4%BE%86%E5%BE%9E%E8%A1%A8%E4%B8%AD%E9%81%B8%E6%93%87%E8%A1%8C%EF%BC%8C%E5%85%B6%E4%B8%AD%E5%88%97%E7%9A%84%E5%80%BC%E8%88%87%E6%9F%90%E4%BA%9B%E5%80%BC%E5%8C%B9%E9%85%8D%EF%BC%8C%E9%80%99%E4%BA%9B%E5%80%BC%E5%AD%98%E5%84%B2%E7%82%BA%E5%88%97%E8%A1%A8%E3%80%82%E4%BD%86%E6%98%AF%EF%BC%8C%E6%B8%85%E5%96%AE%E4%B8%AD%E5%8F%AF%E4%BB%A5%E5%8C%85%E5%90%AB%E4%BB%BB%E6%84%8F%E6%95%B8%E9%87%8F%E7%9A%84%E9%A0%85%E7%9B%AE%E3%80%82%3CBR%20%2F%3E%3CBR%20%2F%3E%E6%88%91%E5%B7%B2%E7%B6%93%E5%98%97%E8%A9%A6%E4%BA%86%E8%A8%8A%E6%81%AF%E5%BA%95%E9%83%A8%E7%9A%84%E7%A8%8B%E5%BC%8F%E7%A2%BC%EF%BC%88%E5%85%B6%E4%B8%AD%20b1%20%E6%98%AF%E5%8C%85%E5%90%AB%E8%A6%81%E9%81%B8%E6%93%87%E7%9A%84%E5%80%BC%E7%9A%84%E5%88%97%E8%A1%A8%EF%BC%8C%3ALot%20%E6%98%AF%E8%A6%81%E6%AF%94%E8%BC%83%E7%9A%84%E5%88%97%EF%BC%8Cdt2%20%E6%98%AF%E8%A6%81%E5%BE%9E%E4%B8%AD%E9%81%B8%E6%93%87%E7%9A%84%E8%B3%87%E6%96%99%E8%A1%A8%EF%BC%89%EF%BC%8C%E4%BD%86%E9%80%99%E5%8F%AA%E6%98%AF%E9%81%B8%E6%93%87%E5%8C%B9%E9%85%8D%E7%9A%84%E8%A1%8Cb1%5B%E6%9C%80%E5%BE%8C1%5D%20%E3%80%82%E6%88%91%E7%9F%A5%E9%81%93%E6%88%91%E5%8F%AF%E4%BB%A5%E7%82%BA%20b1%5Bjj%5D%20%E7%9A%84%E6%AF%8F%E5%80%8B%E5%80%BC%E7%94%A2%E7%94%9F%E4%B8%80%E5%80%8B%E5%AD%90%E9%9B%86%E8%A1%A8%EF%BC%8C%E7%84%B6%E5%BE%8C%E5%B0%87%E5%AE%83%E5%80%91%E9%80%A3%E6%8E%A5%E8%B5%B7%E4%BE%86%EF%BC%8C%E4%BD%86%E9%80%99%E5%BE%88%E6%B7%B7%E4%BA%82%EF%BC%8C%E4%B8%A6%E4%B8%94%E6%9C%83%E5%9C%A8%E4%BB%A5%E5%BE%8C%E5%B0%8E%E8%87%B4%E5%AE%83%E8%87%AA%E5%B7%B1%E7%9A%84%E5%95%8F%E9%A1%8C%E3%80%82%3CBR%20%2F%3E%3CBR%20%2F%3E%E6%88%91%E9%82%84%E5%98%97%E8%A9%A6%E4%BA%86%20Eval(Substitute(Expr(%20%E9%A1%9E%E5%9E%8B%E7%B5%90%E6%A7%8B)%EF%BC%8C%E4%BD%86%E9%80%99%E4%B8%8D%E8%B5%B7%E4%BD%9C%E7%94%A8%E3%80%82%3CBR%20%2F%3E%3CBR%20%2F%3E%E6%9C%89%E4%BA%BA%E6%9C%89%E4%BB%80%E9%BA%BC%E6%83%B3%E6%B3%95%E5%97%8E%EF%BC%9F%E6%88%96%E8%80%85%E6%88%91%E7%9A%84%E8%99%95%E7%90%86%E6%96%B9%E5%BC%8F%E5%AE%8C%E5%85%A8%E9%8C%AF%E8%AA%A4%E5%97%8E%EF%BC%9F%3CBR%20%2F%3E%3CBR%20%2F%3E%E4%B9%BE%E6%9D%AF%EF%BC%8C%3CBR%20%2F%3E%3CBR%20%2F%3E%E9%A6%AC%E4%BF%AE%E3%80%82%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EFor(%20jj%20%3D%201%2C%20jj%20%26lt%3B%3D%20last1%2C%20jj%2B%2B%2C%0Adt2%20%26lt%3B%26lt%3B%20Select%20Where(%20%3ALot%20%3D%3D%20b1%5Bjj%5D%20)%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-769072%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%9B%9E%E8%A6%86%EF%BC%9A%E9%81%B8%E6%93%87%E4%BD%8D%E7%BD%AE%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-769072%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E5%97%A8%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F6878%22%20target%3D%22_blank%22%3E%40Jeff_Perkinson%3C%2FA%3E%20%EF%BC%8C%E6%98%AF%E5%90%A6%E6%9C%89%E9%A1%9E%E4%BC%BC%E7%9A%84%E6%8A%80%E5%B7%A7%E5%8F%AF%E4%BB%A5%E8%88%87%E6%96%B0%E7%9A%84Where%E4%B8%80%E8%B5%B7%E4%BD%BF%E7%94%A8%EF%BC%9F%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%3Dopen(%22%24SAMPLE_DATA%5CBig%20Class.jmp%22)%3B%0A%0Aages%3D%7B13%2C%2014%2C%2015%7D%3B%0A%0Adt%26lt%3B%3CSELECT%20where%3D%22%22%3E%20%3C%2FSELECT%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%0A%20%0A%20%0A%20%20%3CLINGO-SUB%20id%3D%22lingo-sub-893488%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%9B%9E%E8%A6%86%EF%BC%9A%E9%81%B8%E6%93%87%E4%BD%8D%E7%BD%AE%3C%2FLINGO-SUB%3E%0A%20%20%3CLINGO-BODY%20id%3D%22lingo-body-893488%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%0A%20%20%20%3CBLOCKQUOTE%3E%3CHR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F26800%22%20target%3D%22_blank%22%3E%40hogi%3C%2FA%3E%E5%AF%AB%E9%81%93%EF%BC%9A%3CBR%20%2F%3E%3CP%3E%E4%BD%A0%E5%A5%BD%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F6878%22%20target%3D%22_blank%22%3E%40Jeff_Perkinson%3C%2FA%3E%20%EF%BC%8C%E6%9C%89%E6%B2%92%E6%9C%89%E9%A1%9E%E4%BC%BC%E7%9A%84%E6%8A%80%E5%B7%A7%E5%8F%AF%E4%BB%A5%E8%88%87%E6%96%B0%E7%9A%84%20Where%20%E4%B8%80%E8%B5%B7%E4%BD%BF%E7%94%A8%EF%BC%9F%3C%2FP%3E%3CHR%20%2F%3E%3C%2FBLOCKQUOTE%3E%20%0A%20%20%20%3CBR%20%2F%3E%20%0A%20%20%20%3CP%3E%E4%B8%8D%E5%B9%B8%E7%9A%84%E6%98%AF%EF%BC%8C%E6%B2%92%E6%9C%89%E8%A7%A3%E6%B1%BA%E6%96%B9%E6%A1%88%EF%BC%9ATS-00225505%3CBR%20%2F%3E%3CEM%3E%E5%88%97%E8%A1%A8%E3%80%81%E7%9F%A9%E9%99%A3%E5%92%8C%E5%88%97%E5%9D%87%E5%81%87%E5%AE%9A%E5%9C%A8%20Where%20%E4%B8%AD%E4%B8%80%E8%B5%B7%E8%AE%8A%E5%8C%96%E3%80%82%E7%9B%AE%E5%89%8D%E6%B2%92%E6%9C%89%E8%BE%A6%E6%B3%95%E9%81%BF%E5%85%8D%2F%E9%98%BB%E6%AD%A2%E9%80%99%E7%A8%AE%E6%83%85%E6%B3%81%3C%2FEM%3E%3CSTRONG%3E%3CBR%20%2F%3E%3C%2FSTRONG%3E%3C%2FP%3E%20%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%3C%2FLINGO-BODY%3E%0A%20%0A%20%0A%20%20%3CLINGO-SUB%20id%3D%22lingo-sub-893489%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%9B%9E%E8%A6%86%EF%BC%9A%E9%81%B8%E6%93%87%E4%BD%8D%E7%BD%AE%3C%2FLINGO-SUB%3E%0A%20%20%3CLINGO-BODY%20id%3D%22lingo-body-893489%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%0A%20%20%20%3CP%3E-%26gt%3B%20%E6%96%B0%E5%A2%9E%E5%88%B0%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2FDiscussions%2FTiny-Traps-in-Jmp-and-JSL%2Fm-p%2F702685%23U702685%22%20class%3D%22lia-mention-container-editor-message%20lia-img-icon-forum-thread%20lia-fa-icon%20lia-fa-forum%20lia-fa-thread%20lia-fa%22%20target%3D%22_blank%22%3EJmp%20%E5%92%8C%20JSL%20%E4%B8%AD%E7%9A%84%20Tiny%20Traps%3C%2FA%3E%3C%2FP%3E%0A%20%20%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
matthewh
Level I

Select rows where column values match items in an arbitrary list

Hi,

I am trying to write some JSL code to select rows from a table where the value of a column matches some values, which are stored as a list. However, the list may have an arbitrary number of items in it.

I have tried the code at the bottom of the message (where b1 is the list containing my values to be selected, :Lot is the column to compare against and dt2 is the data table to be selected from) but that just selects the rows matching b1[last1]. I know I could produce a subset table for each value of b1[jj] and concatenate them afterwards, but that is messy and causes it's own problems later.

I also tried an Eval(Substitute(Expr( type structure but that didn't work.

Does anyone have any ideas? Or am I going about this completely the wrong way?

Cheers,

Matthew.

For( jj = 1, jj <= last1, jj++,
dt2 << Select Where( :Lot == b1[jj] )
);
1 ACCEPTED SOLUTION

Accepted Solutions
Jeff_Perkinson
Community Manager Community Manager

Re: Select Where

Hi Matthew,

Try the contains() function.

dt=open("$SAMPLE_DATA\Big Class.jmp");

ages={13, 14, 15};

dt<<select where(contains(ages, age));
-Jeff

View solution in original post

17 REPLIES 17
afterword
Level IV

Re: Select Where

Are you trying to select all the rows at once? as in

select all rows matching b1[1], b1[2]...,
perform operation

Or are you trying to match the list sequentially and then perform some operation on the matching cells?

select rows matching b1[1],
perform operation,
select rows matching b1[2],
perform operation,
...
matthewh
Level I

Re: Select Where

I'm trying to select all rows that match the list then perform an operation on those rows.

Re: Select Where

Hey did you ever figure out a solution to this? I am seeking a similar JSL for a data set and am unable to get the Select where function to select more than one condition. The current JSL I have is Data Table( Untitled ) << select where (:Name 2 == ABC OR DEF).

This doesnt work. It works for selecting the first condition, but no any subsequent ones. Any assistance or guidance will be appreciated. Thanks.

Message was edited by: DLW

Message was edited by: DLW
matthewh
Level I

Re: Select Where

Hi,

unfortunately I didn't manage to solve this! I'm hopeful one of the JMP gurus on the forum can help here.

Cheers,

Matthew.

Re: Select Where

If you are not attached to "Select Where", one can try:

For( jj = 1, jj <= N Items(b1), jj++,
For each row( If (:Lot == b1[jj],
Selected(RowState()) = 1)
));
Jeff_Perkinson
Community Manager Community Manager

Re: Select Where

Hi Matthew,

Try the contains() function.

dt=open("$SAMPLE_DATA\Big Class.jmp");

ages={13, 14, 15};

dt<<select where(contains(ages, age));
-Jeff

Re: Select Where

hi, Jeff

i hv tried, the script seems working to ur datatable but not mine.

could u pls help if column name : vendor, contain AABC, DAAF, GIAA
how to write the script to select where vendor name contain AA?

THanks!
ms
Super User (Alumni) ms
Super User (Alumni)

Re: Select Where

Try this:

dt<<select where(contains(:vendor,"AA"));
hogi
Level XIII

Re: Select Where

Hi @Jeff_Perkinson , is there a similar trick which can be used together with the new Where?

dt=open("$SAMPLE_DATA\Big Class.jmp");

ages={13, 14, 15};

dt<<select where(contains(ages, :age));

//how to make this work?
where(dt, contains(ages, :age));
where(dt, contains(ages, :age[]));
where(dt, contains(ages, As Column(:age)))

hogi_0-1719516288577.png

 

Recommended Articles