cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Sean_ShCn0
Level II

How to use a simplest script for subset ?

set table aircraft incidents as a sample data to explain what function I want to get.

  • subset all row, when the charators in column starts "Accident Number". 
  • there is way--> select data filter-->filling "LA"-->manual select all list out items, then copy the scripts as following
  • this script is really very long, another disadvantage is when there are some new accident number start with "CH" but not include in the specified charaters in the script, this item will be unselected. it will not flollow the intention "filter our items start with CH"

Please help me to consider some simple way to make it. thanks a lot!

 

// → Data Table( "Subset of Aircraft Incidents" )
Data Table( "Aircraft Incidents" ) << Select Where(
:Accident Number == "CHI01FA064" | :Accident Number == "CHI01FA067" |
:Accident Number == "CHI01FA077" | :Accident Number == "CHI01FA080" |
:Accident Number == "CHI01FA083" | :Accident Number == "CHI01FA084" |
:Accident Number == "CHI01FA085" | :Accident Number == "CHI01FA089" |
:Accident Number == "CHI01FA093" | :Accident Number == "CHI01FA100" |
:Accident Number == "CHI01FA104" | :Accident Number == "CHI01FA111" |
:Accident Number == "CHI01FA113" | :Accident Number == "CHI01FA117" |
:Accident Number == "CHI01FA128" | :Accident Number == "CHI01FA129" |
:Accident Number == "CHI01FA130" | :Accident Number == "CHI01FA136" |
:Accident Number == "CHI01FA139" | :Accident Number == "CHI01FA146" |
:Accident Number == "CHI01FA165" | :Accident Number == "CHI01FA169" |
:Accident Number == "CHI01FA180" | :Accident Number == "CHI01FA186" |
:Accident Number == "CHI01FA204" | :Accident Number == "CHI01FA206" |
:Accident Number == "CHI01FA209" | :Accident Number == "CHI01FA218" |
:Accident Number == "CHI01FA220" | :Accident Number == "CHI01FA230" |
:Accident Number == "CHI01FA231" | :Accident Number == "CHI01FA232" |
:Accident Number == "CHI01FA233" | :Accident Number == "CHI01FA234" |
:Accident Number == "CHI01FA235" | :Accident Number == "CHI01FA244" |
:Accident Number == "CHI01FA247" | :Accident Number == "CHI01FA256" |
:Accident Number == "CHI01FA257" | :Accident Number == "CHI01FA270" |
:Accident Number == "CHI01FA290" | :Accident Number == "CHI01FA291" |
:Accident Number == "CHI01FA292" | :Accident Number == "CHI01FA297" |
:Accident Number == "CHI01FA298" | :Accident Number == "CHI01FA312" |
:Accident Number == "CHI01FA329" | :Accident Number == "CHI01IA073" |
:Accident Number == "CHI01IA124" | :Accident Number == "CHI01IA211" |
:Accident Number == "CHI01IA246" | :Accident Number == "CHI01IA248A" |
:Accident Number == "CHI01IA248B" | :Accident Number == "CHI01LA057" |
:Accident Number == "CHI01LA060" | :Accident Number == "CHI01LA061" |
:Accident Number == "CHI01LA062" | :Accident Number == "CHI01LA065" |
:Accident Number == "CHI01LA066" | :Accident Number == "CHI01LA068" |
:Accident Number == "CHI01LA069" | :Accident Number == "CHI01LA070" |
:Accident Number == "CHI01LA071" | :Accident Number == "CHI01LA072" |
:Accident Number == "CHI01LA074" | :Accident Number == "CHI01LA075" |
:Accident Number == "CHI01LA076" | :Accident Number == "CHI01LA078" |
:Accident Number == "CHI01LA079" | :Accident Number == "CHI01LA081" |
:Accident Number == "CHI01LA082" | :Accident Number == "CHI01LA086" |
:Accident Number == "CHI01LA088" | :Accident Number == "CHI01LA090" |
:Accident Number == "CHI01LA091" | :Accident Number == "CHI01LA092" |
:Accident Number == "CHI01LA094" | :Accident Number == "CHI01LA095" |
:Accident Number == "CHI01LA096" | :Accident Number == "CHI01LA097" |
:Accident Number == "CHI01LA098" | :Accident Number == "CHI01LA099" |
:Accident Number == "CHI01LA101" | :Accident Number == "CHI01LA103" |
:Accident Number == "CHI01LA105" | :Accident Number == "CHI01LA106" |
:Accident Number == "CHI01LA107" | :Accident Number == "CHI01LA109" |
:Accident Number == "CHI01LA112" | :Accident Number == "CHI01LA114" |
:Accident Number == "CHI01LA115" | :Accident Number == "CHI01LA116" |
:Accident Number == "CHI01LA118" | :Accident Number == "CHI01LA119" |
:Accident Number == "CHI01LA120" | :Accident Number == "CHI01LA121" |
:Accident Number == "CHI01LA122" | :Accident Number == "CHI01LA125" |
:Accident Number == "CHI01LA126" | :Accident Number == "CHI01LA127" |
:Accident Number == "CHI01LA131" | :Accident Number == "CHI01LA132" |
:Accident Number == "CHI01LA133" | :Accident Number == "CHI01LA134" |
:Accident Number == "CHI01LA135" | :Accident Number == "CHI01LA137" |
:Accident Number == "CHI01LA138" | :Accident Number == "CHI01LA140" |
:Accident Number == "CHI01LA141" | :Accident Number == "CHI01LA142" |
:Accident Number == "CHI01LA143" | :Accident Number == "CHI01LA144" |
:Accident Number == "CHI01LA145" | :Accident Number == "CHI01LA147" |
:Accident Number == "CHI01LA148" | :Accident Number == "CHI01LA149" |
:Accident Number == "CHI01LA150" | :Accident Number == "CHI01LA151" |
:Accident Number == "CHI01LA152" | :Accident Number == "CHI01LA153" |
:Accident Number == "CHI01LA154" | :Accident Number == "CHI01LA155" |
:Accident Number == "CHI01LA156" | :Accident Number == "CHI01LA157" |
:Accident Number == "CHI01LA158" | :Accident Number == "CHI01LA159" |
:Accident Number == "CHI01LA160" | :Accident Number == "CHI01LA161" |
:Accident Number == "CHI01LA162" | :Accident Number == "CHI01LA164" |
:Accident Number == "CHI01LA166" | :Accident Number == "CHI01LA167" |
:Accident Number == "CHI01LA168" | :Accident Number == "CHI01LA170" |
:Accident Number == "CHI01LA171" | :Accident Number == "CHI01LA172" |
:Accident Number == "CHI01LA173" | :Accident Number == "CHI01LA174" |
:Accident Number == "CHI01LA175" | :Accident Number == "CHI01LA176" |
:Accident Number == "CHI01LA177" | :Accident Number == "CHI01LA178" |
:Accident Number == "CHI01LA179" | :Accident Number == "CHI01LA181" |
:Accident Number == "CHI01LA182" | :Accident Number == "CHI01LA183" |
:Accident Number == "CHI01LA184" | :Accident Number == "CHI01LA185" |
:Accident Number == "CHI01LA187" | :Accident Number == "CHI01LA188" |
:Accident Number == "CHI01LA189" | :Accident Number == "CHI01LA190" |
:Accident Number == "CHI01LA191" | :Accident Number == "CHI01LA192" |
:Accident Number == "CHI01LA193" | :Accident Number == "CHI01LA194" |
:Accident Number == "CHI01LA195" | :Accident Number == "CHI01LA196" |
:Accident Number == "CHI01LA197" | :Accident Number == "CHI01LA198" |
:Accident Number == "CHI01LA199" | :Accident Number == "CHI01LA200" |
:Accident Number == "CHI01LA201" | :Accident Number == "CHI01LA202" |
:Accident Number == "CHI01LA203" | :Accident Number == "CHI01LA205" |
:Accident Number == "CHI01LA207" | :Accident Number == "CHI01LA208" |
:Accident Number == "CHI01LA210" | :Accident Number == "CHI01LA212" |
:Accident Number == "CHI01LA213" | :Accident Number == "CHI01LA214" |
:Accident Number == "CHI01LA215" | :Accident Number == "CHI01LA216" |
:Accident Number == "CHI01LA217" | :Accident Number == "CHI01LA219" |
:Accident Number == "CHI01LA221" | :Accident Number == "CHI01LA222" |
:Accident Number == "CHI01LA223" | :Accident Number == "CHI01LA224" |
:Accident Number == "CHI01LA225" | :Accident Number == "CHI01LA226" |
:Accident Number == "CHI01LA227" | :Accident Number == "CHI01LA228" |
:Accident Number == "CHI01LA229" | :Accident Number == "CHI01LA236" |
:Accident Number == "CHI01LA237" | :Accident Number == "CHI01LA238" |
:Accident Number == "CHI01LA239" | :Accident Number == "CHI01LA240" |
:Accident Number == "CHI01LA242" | :Accident Number == "CHI01LA243" |
:Accident Number == "CHI01LA245" | :Accident Number == "CHI01LA249" |
:Accident Number == "CHI01LA250" | :Accident Number == "CHI01LA251" |
:Accident Number == "CHI01LA252" | :Accident Number == "CHI01LA253" |
:Accident Number == "CHI01LA254" | :Accident Number == "CHI01LA255" |
:Accident Number == "CHI01LA258" | :Accident Number == "CHI01LA259" |
:Accident Number == "CHI01LA260" | :Accident Number == "CHI01LA261" |
:Accident Number == "CHI01LA262" | :Accident Number == "CHI01LA263" |
:Accident Number == "CHI01LA264" | :Accident Number == "CHI01LA265" |
:Accident Number == "CHI01LA266" | :Accident Number == "CHI01LA267" |
:Accident Number == "CHI01LA268" | :Accident Number == "CHI01LA269" |
:Accident Number == "CHI01LA271" | :Accident Number == "CHI01LA272" |
:Accident Number == "CHI01LA273" | :Accident Number == "CHI01LA274" |
:Accident Number == "CHI01LA275" | :Accident Number == "CHI01LA276" |
:Accident Number == "CHI01LA277" | :Accident Number == "CHI01LA278" |
:Accident Number == "CHI01LA279" | :Accident Number == "CHI01LA280" |
:Accident Number == "CHI01LA281" | :Accident Number == "CHI01LA282" |
:Accident Number == "CHI01LA283" | :Accident Number == "CHI01LA284" |
:Accident Number == "CHI01LA285" | :Accident Number == "CHI01LA286" |
:Accident Number == "CHI01LA287" | :Accident Number == "CHI01LA288" |
:Accident Number == "CHI01LA289" | :Accident Number == "CHI01LA293" |
:Accident Number == "CHI01LA294" | :Accident Number == "CHI01LA295" |
:Accident Number == "CHI01LA296" | :Accident Number == "CHI01LA299" |
:Accident Number == "CHI01LA300" | :Accident Number == "CHI01LA301" |
:Accident Number == "CHI01LA302" | :Accident Number == "CHI01LA303" |
:Accident Number == "CHI01LA304" | :Accident Number == "CHI01LA305" |
:Accident Number == "CHI01LA306" | :Accident Number == "CHI01LA307" |
:Accident Number == "CHI01LA308" | :Accident Number == "CHI01LA309" |
:Accident Number == "CHI01LA310" | :Accident Number == "CHI01LA311" |
:Accident Number == "CHI01LA313" | :Accident Number == "CHI01LA314" |
:Accident Number == "CHI01LA315" | :Accident Number == "CHI01LA316" |
:Accident Number == "CHI01LA317" | :Accident Number == "CHI01LA318" |
:Accident Number == "CHI01LA321" | :Accident Number == "CHI01LA322" |
:Accident Number == "CHI01LA323" | :Accident Number == "CHI01LA324" |
:Accident Number == "CHI01LA325" | :Accident Number == "CHI01LA326" |
:Accident Number == "CHI01LA327" | :Accident Number == "CHI01LA328" |
:Accident Number == "CHI01LA330" | :Accident Number == "CHI01LA331" |
:Accident Number == "CHI01LA332" | :Accident Number == "CHI01LA333" |
:Accident Number == "CHI01MA163" | :Accident Number == "CHI01TA063" |
:Accident Number == "CHI02FA001" | :Accident Number == "CHI02FA006" |
:Accident Number == "CHI02FA009" | :Accident Number == "CHI02FA025" |
:Accident Number == "CHI02FA033" | :Accident Number == "CHI02FA034" |
:Accident Number == "CHI02FA042" | :Accident Number == "CHI02FA049" |
:Accident Number == "CHI02FA059" | :Accident Number == "CHI02FAMS1" |
:Accident Number == "CHI02IA050" | :Accident Number == "CHI02IA058" |
:Accident Number == "CHI02LA002" | :Accident Number == "CHI02LA003" |
:Accident Number == "CHI02LA004" | :Accident Number == "CHI02LA005" |
:Accident Number == "CHI02LA007" | :Accident Number == "CHI02LA008" |
:Accident Number == "CHI02LA010" | :Accident Number == "CHI02LA011" |
:Accident Number == "CHI02LA012" | :Accident Number == "CHI02LA013" |
:Accident Number == "CHI02LA014" | :Accident Number == "CHI02LA015" |
:Accident Number == "CHI02LA016" | :Accident Number == "CHI02LA017" |
:Accident Number == "CHI02LA018" | :Accident Number == "CHI02LA019" |
:Accident Number == "CHI02LA020" | :Accident Number == "CHI02LA021" |
:Accident Number == "CHI02LA022" | :Accident Number == "CHI02LA023" |
:Accident Number == "CHI02LA024" | :Accident Number == "CHI02LA026" |
:Accident Number == "CHI02LA027" | :Accident Number == "CHI02LA028" |
:Accident Number == "CHI02LA029" | :Accident Number == "CHI02LA030" |
:Accident Number == "CHI02LA031" | :Accident Number == "CHI02LA032" |
:Accident Number == "CHI02LA035" | :Accident Number == "CHI02LA036" |
:Accident Number == "CHI02LA037" | :Accident Number == "CHI02LA038" |
:Accident Number == "CHI02LA039" | :Accident Number == "CHI02LA040" |
:Accident Number == "CHI02LA041" | :Accident Number == "CHI02LA043" |
:Accident Number == "CHI02LA044" | :Accident Number == "CHI02LA045" |
:Accident Number == "CHI02LA046" | :Accident Number == "CHI02LA047" |
:Accident Number == "CHI02LA048" | :Accident Number == "CHI02LA052" |
:Accident Number == "CHI02LA053" | :Accident Number == "CHI02LA054" |
:Accident Number == "CHI02LA055" | :Accident Number == "CHI02LA056"
) << Subset( Selected Rows( 1 ), Selected columns only( 0 ) );

2 ACCEPTED SOLUTIONS

Accepted Solutions
jthi
Super User

Re: How to use a simplest script for subset ?

If you just the rows in which :Accident Number starts with CH you can use Starts With()

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Aircraft Incidents.jmp");

dt << Select Where(Starts With(:Accident Number, "CH"));

And with subset I would use Get Rows Where

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Aircraft Incidents.jmp");

rows_of_interest = dt << Get Rows Where(Starts With(:Accident Number, "CH"));

dt_ch = dt << Subset(Rows(rows_of_interest), Selected Columns(0), Output Table("CH Accidents"));
-Jarmo

View solution in original post

mmarchandFSLR
Level IV

Re: How to use a simplest script for subset ?

It looks like this would suffice.

 

Data Table( "Aircraft Incidents" ) << Select Where( Starts With( :Accident Number, "CH" ) )

View solution in original post

5 REPLIES 5
jthi
Super User

Re: How to use a simplest script for subset ?

If you just the rows in which :Accident Number starts with CH you can use Starts With()

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Aircraft Incidents.jmp");

dt << Select Where(Starts With(:Accident Number, "CH"));

And with subset I would use Get Rows Where

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Aircraft Incidents.jmp");

rows_of_interest = dt << Get Rows Where(Starts With(:Accident Number, "CH"));

dt_ch = dt << Subset(Rows(rows_of_interest), Selected Columns(0), Output Table("CH Accidents"));
-Jarmo
Sean_ShCn0
Level II

Re: How to use a simplest script for subset ?

Thanks, it works well, in another case, if i changes a little bit for the requirment, i want sort all items which contains "CH" charaters no matter it is the first two charaters, may be the "CH" is in the middle for Accident Number string. how i should change the script ? Thanks a lot!

jthi
Super User

Re: How to use a simplest script for subset ?

Then you can use Contains()

dt << Select Where(Contains(:Accident Number, "CH"));

I suggest reading this bit older blog post JSL Character String Functions for some basic (and munger which I don't use). Also JSL Syntax Reference > JSL Functions, Operators, and Messages > Character Functions

-Jarmo
Sean_ShCn0
Level II

Re: How to use a simplest script for subset ?

Thanks a lot!

mmarchandFSLR
Level IV

Re: How to use a simplest script for subset ?

It looks like this would suffice.

 

Data Table( "Aircraft Incidents" ) << Select Where( Starts With( :Accident Number, "CH" ) )