cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
GCardin
Level I

Is there a way to create a report for 2 column switcher simultaneously ?

Hi,

I wanted to run multiple t-test where I have a list of multiple X and Ys. Is there a way to do this using a script ? I modified slightly the script I am using for 1 column switcher but I can't figure out how to do them both at the same time. For exemple this smaller test (3x3):

 

Oneway(
	Y(:Name("A")),
	X(:Name("1")),
	t Test(1),
	Column Switcher(:Name("A"), {:Name("A"), :Name("B"), :Name("C")}),
	Column Switcher(:Name("1"), {:Name("1"), :Name("2"), :Name("3")})
);

rpt = Current Report();
colswitcher_obj = rpt[ColumnSwitcherCOntextOutlinebox(1)] << get scriptable object;
colswitch_list = colswitcher_obj << get list;

/* Loop through each column in the colswitch_list */
For(i = 1, i <= N Items(colswitch_list), i++, 

/* Change here */
	dt1 = rpt[Outline Box("t Test")][Table Box(1)] << make combined data table;

/* Concatenate the tables */
	If(i == 1,
		main_tb = dt1;
		main_tb << Set Name("All");
	,
		Try(main_tb << Concatenate(dt1, Append to First Table));
		Close(dt1, No Save);
	);

/* Close temporary tables and switch next column */
	colSwitcher_obj << Next;
);

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Is there a way to create a report for 2 column switcher simultaneously ?

You are using wrong column switcher object references inside your loops (inner loop which has N Items(colswitch_list2) should change colSwitcher_obj2 << Next).

jthi_1-1716992154852.png

Also use
jthi_0-1716992111616.png

when posting JSL to JMP Community as it makes reading the post much easier.

-Jarmo

View solution in original post

5 REPLIES 5
jthi
Super User

Re: Is there a way to create a report for 2 column switcher simultaneously ?

Is there a specific reason to use column switcher for this? You could just loop over your columns, re-create report as you go and extract results.

-Jarmo
GCardin
Level I

Re: Is there a way to create a report for 2 column switcher simultaneously ?

I fixed my problem with the following script, but when I run it on the full database, JMP crashes (memory issue I assume), any idea how I could go around the memory issue ?

 

Oneway(
Y( :Name( "A" ) ),
X( :Name( "1" ) ),
t Test( 1 ),
Column Switcher( :Name( "1" ), {:Name( "1" ), :Name( "2" ), :Name( "3" )} ),
Column Switcher(
:Name( "A" ),
{:Name( "A" ), :Name( "B" ), :Name( "C" )}
)
);
rpt = Current Report();
colswitcher_obj = rpt[ColumnSwitcherCOntextOutlinebox( 1 )] << get scriptable object;
colswitcher_obj2 = rpt[ColumnSwitcherCOntextOutlinebox( 2 )] << get scriptable object;
colswitch_list = colswitcher_obj << get list;

// Loop through each Y variable
For(j = 1, j <= N Items(colswitch_list), j++,

// Loop through each X variable
For(k = 1, k <= N Items(colswitch_list), k++,

/* Change here */
dt1 = rpt[Outline Box( "t Test" )][Table Box( 1 )] << Make Combined Data Table;

/* Concatenate the tables */
If(j == 1 & k == 1,
main_tb = dt1;
main_tb << Set Name( "All" );
,
Try( main_tb << Concatenate( dt1, Append to First Table ) );
Close( dt1, No Save );
);

// Switch to next X column
colSwitcher_obj << Next;
);

// Switch to next Y column
colSwitcher_obj2 << Next;
);

jthi
Super User

Re: Is there a way to create a report for 2 column switcher simultaneously ?

Difficult to say without knowing anything about your data. You could for example run into issue where one of your columns has massive amounts of categories and that is causing issues. Maybe adding wait(0); after each << next could help it a little, but the script will still be most likely very slow.

 

Also, I think you are using incorrect max count for your k variable at least (shouldn't it be N Items(col_switch_list2)).

-Jarmo
GCardin
Level I

Re: Is there a way to create a report for 2 column switcher simultaneously ?

Indeed you are right, now it works perfectly for a 10x10 of columns (see script below).

But I have an issue that if I don't have exactly the same number of X columns than of Y columns, the switching doesn't work ! Any idea please what I am doing wrong ?

 

// Analysis and column switchers
Oneway(
Y(:Name("553")),
X(:Name("1")),
t Test(1),
Column Switcher(:Name("1"), {:Name("1"), :Name("2"), :Name("3"), :Name("4"), :Name("5"), :Name("6"), :Name("7"), :Name("8"), :Name("9"), :Name("10")}),
Column Switcher(:Name("553"), {:Name("553"), :Name("554"), :Name("555"), :Name("556"), :Name("557"), :Name("558"), :Name("559"), :Name("560"), :Name("561"), :Name("562")}));

//Report creation
rpt = Current Report();
colswitcher_obj = rpt[ColumnSwitcherCOntextOutlinebox( 1 )] << get scriptable object;
colswitcher_obj2 = rpt[ColumnSwitcherCOntextOutlinebox( 2 )] << get scriptable object;
colswitch_list = colswitcher_obj << get list;
colswitch_list2 = colswitcher_obj2 << get list;

// Loop through each Y variable
For(j = 1, j <= N Items(colswitch_list), j++,

// Loop through each X variable
For(k = 1, k <= N Items(colswitch_list2), k++,

/* Change here */
dt1 = rpt[Outline Box( "t Test" )][Table Box( 1 )] << Make Combined Data Table;

/* Concatenate the tables */
If(j == 1 & k == 1,
main_tb = dt1;
main_tb << Set Name( "All" );
,
Try( main_tb << Concatenate( dt1, Append to First Table ) );
Close( dt1, No Save );
);

// Switch to next X column
colSwitcher_obj << Next;
wait(0);
);

// Switch to next Y column
colSwitcher_obj2 << Next;
wait(0);
);

jthi
Super User

Re: Is there a way to create a report for 2 column switcher simultaneously ?

You are using wrong column switcher object references inside your loops (inner loop which has N Items(colswitch_list2) should change colSwitcher_obj2 << Next).

jthi_1-1716992154852.png

Also use
jthi_0-1716992111616.png

when posting JSL to JMP Community as it makes reading the post much easier.

-Jarmo