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
- :
- JSL scripting: can I automate the SendToByGroup co...

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

Oct 10, 2014 8:07 AM
(1034 views)

Most JMP platforms have a "By" option which performs the analysis separately for each level of a variable. I am particularly interested in the Distribution and the Fit Model (GLM) platforms.

The Scripting Index (accessible through the help menu) gives this example:

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

Distribution(

By( :Sex ),

SendToByGroup(

{:sex == "F"},

Continuous Distribution(

Column( :weight ),

Normal Quantile Plot( 1 )

)

),

SendToByGroup(

{:sex == "M"},

Continuous Distribution(

Column( :weight )

)

)

);

In the example above, and in the scripts I can generate through the Fit Model platform, the levels of the variable are specified explicitly.

Can a script automate the execution for whatever the levels are in the dataset? E.g. I'd like not to specify the levels manually, because I need to repeat the same analysis on different datasets, each of which has different levels. Think of an analysis by city, with one dataset having NY and LA, another having London and Paris, etc.

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions

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

Solution

NamesDefaultToHere**(****1****)**;

// Make a table with a 'By' variable with a random number of levels (between 2 and 5)

nr = **100**;

nc = **3**;

dt = NewTable**(**"Some Data"**)**;

For**(**c=**1**, c<=nc, c++,

dt << **NewColumn****(**"Col "||Char**(**c**)**, Numeric, Continuous, Formula**(**RandomNormal**()))**;

**)**;

dt << **AddRows****(**nr**)**;

cols = dt << **GetColumnNames****(**"String"**)**;

dt << **NewColumn****(**"By", Numeric, Continuous, Formula**(**RandomInteger**(****1**, RandomInteger**(****2**,**5****))))**;

// Do distribution

dt << **Distribution****(**Columns**(**Eval**(**cols**))**, By**(** :By **))**;

2 REPLIES

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

NamesDefaultToHere**(****1****)**;

// Make a table with a 'By' variable with a random number of levels (between 2 and 5)

nr = **100**;

nc = **3**;

dt = NewTable**(**"Some Data"**)**;

For**(**c=**1**, c<=nc, c++,

dt << **NewColumn****(**"Col "||Char**(**c**)**, Numeric, Continuous, Formula**(**RandomNormal**()))**;

**)**;

dt << **AddRows****(**nr**)**;

cols = dt << **GetColumnNames****(**"String"**)**;

dt << **NewColumn****(**"By", Numeric, Continuous, Formula**(**RandomInteger**(****1**, RandomInteger**(****2**,**5****))))**;

// Do distribution

dt << **Distribution****(**Columns**(**Eval**(**cols**))**, By**(** :By **))**;

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

Oct 10, 2014 9:35 AM
(799 views)