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
psundar6
Level III

How do I get Comma separated user input to subset rows with specific value?

Hi, I have a data table that contains information in the below format. I'd like to create a button on jmp that when clicked should prompt to enter a list of comma separated values from the user (possibly in a text box?) to subset just the rows with that value in a specific column.


For example in the text box if the user chooses BB,EE, then in the attached table (sample_table.jmp) only those rows will be subsetted out to form a new table.

 

How do I accomplish this using JSL? Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How do I get Comma separated user input to subset rows with specific value?

Here is one of the many ways this can be done

names default to here( 1 );
dt = Current Data Table();
dt << clear select;

NW = New Window( "Select",
	V List Box(
		Text Box( "Input a comma separated list th the Names you want subsetted" ),
		teb = Text Edit Box( "", <<set width( 150 ) ),
		Button Box( "OK",
			i = 1;
			val = teb << get text;
			While( Word( i, val, "," ) != "",
				theWord = Word( i, val, "," );
				dt << select where( :name == theWord, current selection( "extend" ) );
				i++;
			);
			dtSub = dt << subset( selected rows( 1 ), selected columns( 0 ) );
		)
	)
);
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: How do I get Comma separated user input to subset rows with specific value?

Here is one of the many ways this can be done

names default to here( 1 );
dt = Current Data Table();
dt << clear select;

NW = New Window( "Select",
	V List Box(
		Text Box( "Input a comma separated list th the Names you want subsetted" ),
		teb = Text Edit Box( "", <<set width( 150 ) ),
		Button Box( "OK",
			i = 1;
			val = teb << get text;
			While( Word( i, val, "," ) != "",
				theWord = Word( i, val, "," );
				dt << select where( :name == theWord, current selection( "extend" ) );
				i++;
			);
			dtSub = dt << subset( selected rows( 1 ), selected columns( 0 ) );
		)
	)
);
Jim
psundar6
Level III

Re: How do I get Comma separated user input to subset rows with specific value?

Thanks Jim! That does it.