cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. ET on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar

how to select rows with a specific number that user input

Hello everyone,

 

I am working on a project that helps users to pick modules based on their input. For example, if user input 5, the script would give user 5 modules that been selected. Could anyone one help me with the "select" part?

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: how to select rows with a specific number that user input

This should work

Names Default To Here( 1 );
dt << Select Where( Column( "Shippable to Reliability?" )[Row()] == 1 );
dtsub = dt << Subset( Selected Rows( 1 ), Output Table( "Best Modules" ) );

dtsub << New Column( "random", formula( Random Uniform() ) );

dtsub = dtsub << sort( by( :random ), order( ascending ), replace table( 1 ) );

dtsub << select where( Row() > 5 );
dtsub << delete rows;
dtsub << delete columns("random");
Jim

View solution in original post

gzmorgan0
Super User (Alumni)

Re: how to select rows with a specific number that user input

Just for fun, an alternate method.  

Names Default To Here( 1 );
dt   = open("$sample_data/big class.jmp");
idx  = Random Shuffle( dt <<  Get Rows Where( Column( "sex" )[]== "F" ) );
//get the matching rows but mix up the order;
show(idx); //for demonstration

//use only 5 of them
dtsub =  << Subset( rows(idx[1::5]), Output Table( "Best Modules" ) );

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: how to select rows with a specific number that user input

This should work

Names Default To Here( 1 );
dt << Select Where( Column( "Shippable to Reliability?" )[Row()] == 1 );
dtsub = dt << Subset( Selected Rows( 1 ), Output Table( "Best Modules" ) );

dtsub << New Column( "random", formula( Random Uniform() ) );

dtsub = dtsub << sort( by( :random ), order( ascending ), replace table( 1 ) );

dtsub << select where( Row() > 5 );
dtsub << delete rows;
dtsub << delete columns("random");
Jim
gzmorgan0
Super User (Alumni)

Re: how to select rows with a specific number that user input

Just for fun, an alternate method.  

Names Default To Here( 1 );
dt   = open("$sample_data/big class.jmp");
idx  = Random Shuffle( dt <<  Get Rows Where( Column( "sex" )[]== "F" ) );
//get the matching rows but mix up the order;
show(idx); //for demonstration

//use only 5 of them
dtsub =  << Subset( rows(idx[1::5]), Output Table( "Best Modules" ) );

Re: how to select rows with a specific number that user input

Thank you so much for your help! 

Recommended Articles