cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
danielsh
Level I

How can I automate random row selection?

Hello All,

I'm pretty new to JMP and even newer to JSL. I'm trying to write a script that subsets a number of rows based on the following specifications: if the original table has 1-15 rows, then the subset  of the original table is 2 rows, if the original has 16-25 then the subset of that table is 3 rows, if the orginal has 26-90 then the subset table is 5 rows, etc. Basically just a script to automate .

subset>random-sample size: [user inputs number] >ok based on a specified range of rows. So far I've tried the following:

New Script ("Random Row Check,

if (n row==1::15, current data table()<<subset(sample size(2))),

if (n row==16::25, current data table()<<subset(sample size(3))),

if (n row==26::90, current data table()<<subset(sample size(5))),

if (n row==91::150, current data table()<<subset(sample size(6))),

if (n row==151::280,current data table()<<subset(sample size(7))),

if (n row==281::500, current data table()<<subset(sample size(9))),

if (n row >=501, current data table()<<subset(sample size(15))),

)

This script returns an empty data table. I know this must be something simple, but I can't seem to the forest for the the trees. Thanks for any help!


1 ACCEPTED SOLUTION

Accepted Solutions
pmroz
Super User

Re: How can I automate random row selection?

You're almost there.  Try this:

n = nrows(current data table());

if (n <= 15,  current data table() << subset(sample size(2)),

    n <= 25,  current data table() << subset(sample size(3)),

    n <= 90,  current data table() << subset(sample size(5)),

    n <= 150, current data table() << subset(sample size(6)),

    n <= 280, current data table() << subset(sample size(7)),

    n <= 500, current data table() << subset(sample size(9)),

    n >= 501, current data table() << subset(sample size(15)),

)

View solution in original post

2 REPLIES 2
pmroz
Super User

Re: How can I automate random row selection?

You're almost there.  Try this:

n = nrows(current data table());

if (n <= 15,  current data table() << subset(sample size(2)),

    n <= 25,  current data table() << subset(sample size(3)),

    n <= 90,  current data table() << subset(sample size(5)),

    n <= 150, current data table() << subset(sample size(6)),

    n <= 280, current data table() << subset(sample size(7)),

    n <= 500, current data table() << subset(sample size(9)),

    n >= 501, current data table() << subset(sample size(15)),

)

danielsh
Level I

Re: How can I automate random row selection?

Thanks so much! This is exactly what I needed