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%3ES%C3%A9lectionnez%20les%20lignes%20o%C3%B9%20les%20valeurs%20des%20colonnes%20correspondent%20aux%20%C3%A9l%C3%A9ments%20d'une%20liste%20arbitraire%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-299%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3ESalut%2C%3CBR%20%2F%3E%3CBR%20%2F%3E%20J'essaie%20d'%C3%A9crire%20du%20code%20JSL%20pour%20s%C3%A9lectionner%20des%20lignes%20d'une%20table%20o%C3%B9%20la%20valeur%20d'une%20colonne%20correspond%20%C3%A0%20certaines%20valeurs%2C%20qui%20sont%20stock%C3%A9es%20sous%20forme%20de%20liste.%20Cependant%2C%20la%20liste%20peut%20contenir%20un%20nombre%20arbitraire%20d%E2%80%99%C3%A9l%C3%A9ments.%3CBR%20%2F%3E%3CBR%20%2F%3E%20J'ai%20essay%C3%A9%20le%20code%20au%20bas%20du%20message%20(o%C3%B9%20b1%20est%20la%20liste%20contenant%20mes%20valeurs%20%C3%A0%20s%C3%A9lectionner%2C%20%3ALot%20est%20la%20colonne%20%C3%A0%20comparer%20et%20dt2%20est%20la%20table%20de%20donn%C3%A9es%20%C3%A0%20s%C3%A9lectionner)%20mais%20cela%20s%C3%A9lectionne%20simplement%20les%20lignes%20correspondant%20b1%5Bdernier1%5D.%20Je%20sais%20que%20je%20pourrais%20produire%20une%20table%20de%20sous-ensembles%20pour%20chaque%20valeur%20de%20b1%5Bjj%5D%20et%20les%20concat%C3%A9ner%20ensuite%2C%20mais%20cela%20est%20compliqu%C3%A9%20et%20pose%20ses%20propres%20probl%C3%A8mes%20plus%20tard.%3CBR%20%2F%3E%3CBR%20%2F%3E%20J'ai%20%C3%A9galement%20essay%C3%A9%20une%20structure%20de%20type%20Eval(Substitute(Expr(%20mais%20cela%20n'a%20pas%20fonctionn%C3%A9.%3CBR%20%2F%3E%3CBR%20%2F%3E%20Quelqu'un%20a-t-il%20une%20id%C3%A9e%3F%20Ou%20est-ce%20que%20je%20m'y%20prends%20compl%C3%A8tement%20dans%20le%20mauvais%20sens%20%3F%3CBR%20%2F%3E%3CBR%20%2F%3E%20Acclamations%2C%3CBR%20%2F%3E%3CBR%20%2F%3E%20Matthieu.%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%3ERe%20%3A%20S%C3%A9lectionner%20o%C3%B9%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-769072%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3ESalut%20%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%2C%20existe-t-il%20une%20astuce%20similaire%20qui%20peut%20%C3%AAtre%20utilis%C3%A9e%20avec%20le%20nouveau%20Where%20%3F%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%3ERe%3A%20S%C3%A9lectionner%20o%C3%B9%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%20a%20%C3%A9crit%20%3A%3CBR%20%2F%3E%3CP%3E%20Bonjour%20%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%2C%20existe-t-il%20une%20astuce%20similaire%20qui%20peut%20%C3%AAtre%20utilis%C3%A9e%20avec%20le%20nouveau%20Where%20%3F%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%3Emalheureusement%2C%20il%20n'y%20a%20pas%20de%20solution%20%3ATS-00225505%3CBR%20%2F%3E%20%3CEM%3ELes%20listes%2C%20les%20matrices%20et%20les%20colonnes%20sont%20suppos%C3%A9es%20varier%20ensemble%20au%20sein%20de%20la%20propri%C3%A9t%C3%A9%20Where.%20Il%20n'existe%20actuellement%20aucun%20moyen%20d'%C3%A9viter%20ce%20probl%C3%A8me.%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%3ERe%3A%20S%C3%A9lectionner%20o%C3%B9%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%20ajout%C3%A9%20%C3%A0%20%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%3ETiny%20Traps%20dans%20Jmp%20et%20JSL%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