BookmarkSubscribeSubscribe to RSS Feed
jumper

Community Trekker

Joined:

Oct 7, 2014

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

Staff

Joined:

Jun 23, 2011

Solution

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

2 REPLIES
ian_jmp

Staff

Joined:

Jun 23, 2011

Solution

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

Community Trekker

Joined:

Oct 7, 2014

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.