cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
mvcands
Level I

JSL - Creating a loop for custom distribution report

Hello,

is there a way to create a place holder variable via array that can be substituted into the distribution report layer syntax? The code I have just loops the distribution giving me 10 windows with 10 graphs each with no frame adjustments. I want 1 window with 10 graphs that have had the frame size adjusted.

My Code

/*Run Analyte Array*/

analyteArr = Associative Array(:Analyte) << Get Keys;

For( eachAnalyte = 1, eachAnalyte <= N Items( analyteArr ), eachAnalyte++,

/*Slope Distribution*/

Current Data Table (dtmain);

       dtmain << Distribution(

              Automatic Recalc( 1 ),

              SendToByGroup( {:Analyte == analyteArr[eachAnalyte]} ),

              SendToByGroup(

                     {:Analyte == analyteArr[eachAnalyte]},

                     Continuous Distribution( Column( :Slope ), Vertical( 0 ) )

              ),

              By( :Analyte ),

              SendToByGroup(

                     {:Analyte == analyteArr[eachAnalyte]},

                     SendToReport(

                           Dispatch(

                                  {"Distributions Analyte=" || analyteArr[eachAnalyte], "Slope"},

                                  "Distrib Outlier Box",

                                  FrameBox,

                                  {Frame Size( 550, 50 )}

                           ),

                           Dispatch(

                                  {"Distributions Analyte=" || analyteArr[eachAnalyte], "Slope"},

                                  "Distrib Histogram",

                                  FrameBox,

                                  {Frame Size( 550, 325 )}

                           )

                     )

              )

       )

);

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: JSL - Creating a loop for custom distribution report

Here is your script modified to place all of the distributions into a single window.  I am not clear as to what you mean by "frame size adjusted".  Could you please clarify that?  Is it that you want all of the results shrunk down so they all fit within your display screen?

// Create a display window and place the distributions in it

New Window( "All Together",

// layout the distributions side by side

                H List Box(

/*Run Analyte Array*/

          analyteArr = Associative Array( :Analyte ) << Get Keys;

           For( eachAnalyte = 1, eachAnalyte <= N Items( analyteArr ), eachAnalyte++,

/*Slope Distribution*/

                  Current Data Table( dtmain );

               dtmain << Distribution(

               Automatic Recalc( 1 ),

               SendToByGroup( {:Analyte == analyteArr[eachAnalyte]} ),

               SendToByGroup(

               {:Analyte == analyteArr[eachAnalyte]},

               Continuous Distribution( Column( :Slope ), Vertical( 0 ) )

               ),

               By( :Analyte ),

               SendToByGroup(

               {:Analyte == analyteArr[eachAnalyte]},

               SendToReport(

               Dispatch(

                   {"Distributions Analyte=" || analyteArr[eachAnalyte], "Slope"},

                      "Distrib Outlier Box",

                    FrameBox,

                   {Frame Size( 550, 50 )}

                    ),

              Dispatch(

                   {"Distributions Analyte=" || analyteArr[eachAnalyte], "Slope"},

                       "Distrib Histogram",

                   FrameBox,

                   {Frame Size( 550, 325 )}

                   )

               )

           )

         );

      );

    )

);

Jim

View solution in original post

6 REPLIES 6
txnelson
Super User

Re: JSL - Creating a loop for custom distribution report

Here is your script modified to place all of the distributions into a single window.  I am not clear as to what you mean by "frame size adjusted".  Could you please clarify that?  Is it that you want all of the results shrunk down so they all fit within your display screen?

// Create a display window and place the distributions in it

New Window( "All Together",

// layout the distributions side by side

                H List Box(

/*Run Analyte Array*/

          analyteArr = Associative Array( :Analyte ) << Get Keys;

           For( eachAnalyte = 1, eachAnalyte <= N Items( analyteArr ), eachAnalyte++,

/*Slope Distribution*/

                  Current Data Table( dtmain );

               dtmain << Distribution(

               Automatic Recalc( 1 ),

               SendToByGroup( {:Analyte == analyteArr[eachAnalyte]} ),

               SendToByGroup(

               {:Analyte == analyteArr[eachAnalyte]},

               Continuous Distribution( Column( :Slope ), Vertical( 0 ) )

               ),

               By( :Analyte ),

               SendToByGroup(

               {:Analyte == analyteArr[eachAnalyte]},

               SendToReport(

               Dispatch(

                   {"Distributions Analyte=" || analyteArr[eachAnalyte], "Slope"},

                      "Distrib Outlier Box",

                    FrameBox,

                   {Frame Size( 550, 50 )}

                    ),

              Dispatch(

                   {"Distributions Analyte=" || analyteArr[eachAnalyte], "Slope"},

                       "Distrib Histogram",

                   FrameBox,

                   {Frame Size( 550, 325 )}

                   )

               )

           )

         );

      );

    )

);

Jim
mvcands
Level I

Re: JSL - Creating a loop for custom distribution report

Thank you Jim,

That certainly stops the 10 windows from popping up.

As far as frame size adjuesments, I'm speaking about the part of the code that dictates the frame sizes should be 550, 50 and 550, 325 respectively. Currently, despite having the array variable listed, I'm still getting the default frame sizes of 227, 46 and 277, 110.

txnelson
Super User

Re: JSL - Creating a loop for custom distribution report

The issue is, that you are attempting to change items within a list, and JMP looks at lists and says that a list is just a bunch of stuff, so it isn't going to touch it.  So the method I use to build the lists to the form I want them is to use the Substitute function, and then when I have the list the way I want it, I have JMP evaluate what I have built.  I can not be sure the code below is exactly what you need, but it should be close.  to test out that the Substitute is working correctly, just run eliminate the "Eval" function that surrounds the Substitute command and just run the Substitute command by itself, and it will show the results in the log......

//Create a display window and place the distributions in it

New Window(

      "All Together",

// layout the distributions side by side

      H List Box(

/*Run Analyte Array*/

            analyteArr = Associative Array( :Analyte ) << Get Keys;

            For( eachAnalyte = 1, eachAnalyte <= N Items( analyteArr ), eachAnalyte++,

/*Slope Distribution*/

                  Current Data Table( dtmain );

Eval(

      Substitute(

            Expr(

                  dtmain << Distribution(

                        Automatic Recalc( 1 ),

                        SendToByGroup( {__by__} ),

                        SendToByGroup(

                              {__by__},

                              Continuous Distribution( Column( :Slope ), Vertical( 0 ) )

                        ),

                        By( :Analyte ),

                        SendToByGroup(

                              {__by__},

                              SendToReport(

                                    Dispatch(

                                          {__Dist__, "Slope"},

                                          "Distrib Outlier Box",

                                          FrameBox,

                                          {Frame Size( 550, 50 )}

                                    ),

                                    Dispatch(

                                          {__Dist__, "Slope"},

                                          "Distrib Histogram",

                                          FrameBox,

                                          {Frame Size( 550, 325 )}

                                    )

                              )

                        )

                  );

                  ),Expr(__by__),Parse(":Analyte ==" char(eval( analyteArr[eachAnalyte]))),

                  Expr(__Dist__),"Distributions Analyte=" || char(eval(analyteArr[eachAnalyte])))

                  )

            );

      )

);

Jim
mvcands
Level I

Re: JSL - Creating a loop for custom distribution report

Thank you for the help with this,

This seems to adjust the first of my by variables but not the rest. I think there must be something wrong with the way I'm looping. Not only does it only adjust the first of my by variables, but I just noticed that in the single window I have 100 graphs rather than just the 10 I expected (the 10 x 10 I was getting just all in one window).

txnelson
Super User

Re: JSL - Creating a loop for custom distribution report


You appear to be both looping, and also using  By Grouping.....that maybe what can account for your 10x number of graphs

Jim
vjkrish
Level I

Re: JSL - Creating a loop for custom distribution report

Hi,

This thread helped me to come with a JSL to generate multiple plots. But currently seeing same issue of duplicate plots (like 10x10 instead of 10). Can you share how did you fix it?
I guess 'For' loop and 'By' causing this but if I remove 'By', plots do not come up correctly.