cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
jumper
Level I

JSL scripting: can I automate the SendToByGroup command?

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
ian_jmp
Level X

Re: JSL scripting: can I automate the SendToByGroup command?

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 ));

View solution in original post

2 REPLIES 2
ian_jmp
Level X

Re: JSL scripting: can I automate the SendToByGroup command?

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 ));

jumper
Level I

Re: JSL scripting: can I automate the SendToByGroup command?

Thanks! I was confused because if I run the analysis manually, then do 'copy script, the resulting script specifies the levels explicitly, whereas in fact this is not required.