Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Discussions
- :
- How can I automate random row selection?

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jul 16, 2013 7:52 AM
(3330 views)

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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))**,

**)**

2 REPLIES 2

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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))**,

**)**

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: How can I automate random row selection?

Thanks so much! This is exactly what I needed