Choose Language Hide Translation Bar
Highlighted
Community Trekker

## Scripting platform with BY variable as outer loop

Goal: To script Bivariate plots of three Ys using a BY variable as the outer loop.

Interactively it is easy: Fit Y by X.  Select the three Y columns, Select X. Select the BY variable, in my case "Species".

The resulting Bivariate plots are grouped with the Y(1), Y(2), Y(3) by X plots together for each BY value.

Scripting: I only found inserting BY within each platform call. My try is:

``````Bivariate( Y( :Name( “Y(1)” ) ), X( :X ), By( :Species) ),
Bivariate( Y( :Name( “Y(2)” ) ), X( :X ), By( :Species) ),
Bivariate( Y( :Name( “Y(3)” ) ), X( :X ), By( :Species) ),
<<{Arrange in Rows( 1 )}``````

But the grouping is now Y(1) vs X for all values of Species, then Y(2) for all values of Species, etc.

How can I put the BY variable as the outer loop? The script created from the interactive version is not general, i.e., instead of a BY variable, it explicitly uses WHERE (:Species == "rat"),  etc. The options for the BY variable change with each data set so cannot be explicitly declared using WHERE.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User

## Re: Scripting platform with BY variable as outer loop

There are multiple methods to accomplish your task, using By() , top down, and using Where(), bottom up.

I think building a multivariate report bottom up using Where() provides more flexibility.  Below is a sample script written for JSL Companion, Applications of the JMP Scripting Language, 2nd Edition, Chapter 8, "Custom Displays."

In this example, it is using 2 differnt platforms (Bivariate and Overlay); you will be using 3 bivariate plots for each by group. Instead of Species, it uses States.

This example will work on any subset of states whether there is one state or 52 (including District of Columbia).

Hope this helps.

This is a simple example of building a display "bottom up". This example creates a
custom title and removes a "where" text box. Then appends an OutlineBox containing
an HListBox of the plt1, the bivariate analyses, and plt2, the Oneway analyses.

Note since these plots are single reports, only single analysis navigation is
required. They are in an undisplayed VListBox and will be active since the
final append is the first time the two plots are loaded into a window.

2 REPLIES 2
Highlighted
Super User

## Re: Scripting platform with BY variable as outer loop

There are multiple methods to accomplish your task, using By() , top down, and using Where(), bottom up.

I think building a multivariate report bottom up using Where() provides more flexibility.  Below is a sample script written for JSL Companion, Applications of the JMP Scripting Language, 2nd Edition, Chapter 8, "Custom Displays."

In this example, it is using 2 differnt platforms (Bivariate and Overlay); you will be using 3 bivariate plots for each by group. Instead of Species, it uses States.

This example will work on any subset of states whether there is one state or 52 (including District of Columbia).

Hope this helps.

This is a simple example of building a display "bottom up". This example creates a
custom title and removes a "where" text box. Then appends an OutlineBox containing
an HListBox of the plt1, the bivariate analyses, and plt2, the Oneway analyses.

Note since these plots are single reports, only single analysis navigation is
required. They are in an undisplayed VListBox and will be active since the
final append is the first time the two plots are loaded into a window.

Community Trekker

## Re: Scripting platform with BY variable as outer loop

Thanks for your solution. I had avoided trying a FOR loop because the few steps when doing this interactively were so seductive that I was sure there was an equally simple script using BY.  Your approach will definitely work and with the custom group titles will allow me to copy/paste all the final graphs into my document in one step without having to format/resize each graph by hand.