Choose Language Hide Translation Bar
Highlighted
JPKO
Level III

JSL: Save report by group into tabs

I am trying write a script that saves a report by groups into tabs. As an example let's consider a bivariate analysis of height vs weight in the Big Class example data set. I would like to carry out that analysis by column sex and output the analysis for :sex == "F" in one tab and :sex == "M" in another. Now this should of course work with any number of value levels in the groupby column. The only thing I can think of doing is to subset the datatable but then I end up with a bunch of data tables that I cannot close without loosing my report. Any suggestions on how to do this without subsetting?

0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
txnelson
Super User

Re: JSL: Save report by group into tabs

Here is one way of doing it

tab.PNG

 

names default to here(1);
dt=open("$SAMPLE_DATA/big class.jmp");

// Generate the output in an invisible space
biv = dt << Bivariate( invisible, Y( :height ), X( :weight ), By( :sex ) );

// Create the window, with the first tab
nw=New Window("Tabs", text box("here are the tabs"), tb = Tab Box((report(biv[1])[outlinebox(1)])<<get title ,report(biv[1])));

// Generate the remaining tabs
For( i = 2, i <= N Items( biv ), i++,
	tb << Insert( i, (report(biv[i])[outlinebox(1)])<<get title, Report( biv[i] ) )
);

// Close the invisible output
biv<<close window;
Jim

View solution in original post

7 REPLIES 7
Highlighted
txnelson
Super User

Re: JSL: Save report by group into tabs

Here is one way of doing it

tab.PNG

 

names default to here(1);
dt=open("$SAMPLE_DATA/big class.jmp");

// Generate the output in an invisible space
biv = dt << Bivariate( invisible, Y( :height ), X( :weight ), By( :sex ) );

// Create the window, with the first tab
nw=New Window("Tabs", text box("here are the tabs"), tb = Tab Box((report(biv[1])[outlinebox(1)])<<get title ,report(biv[1])));

// Generate the remaining tabs
For( i = 2, i <= N Items( biv ), i++,
	tb << Insert( i, (report(biv[i])[outlinebox(1)])<<get title, Report( biv[i] ) )
);

// Close the invisible output
biv<<close window;
Jim

View solution in original post

Highlighted
JensRiege
Level III

Re: JSL: Save report by group into tabs

I was successfully able to create a report with tabs with some of the code provided by TxNelson (Thank you Tx !)

Unfortunately when I save the report as an HTML file the tabs are not saved (nor are spacer boxes)

In the case below, I am not getting anything in the html file... Any suggestions are appreciated

 

 

nw = New Window( "Example",
	tb = Tab Box(
		Tab Page Box( "First Tab", Tip( "First Tab Tooltip" ), Button Box( "Press One" ) ),
		Tab Page Box( "Second Tab", Closeable( 1 ), Button Box( "Press Two" ) ),
		Tab Page Box( "Third Tab", Icon( "Nominal" ), Button Box( "Press Three" ) )
	)
);
Wait( 1 );
tb << Add( "Fourth Tab", Button Box( "Press Four" ) );
nw << Journal;
Current Journal() << Save HTML( "C:\_Jens\Test Report.html" );

Web( "C:\_Jens\Test Report.html" );

 

0 Kudos
Highlighted
txnelson
Super User

Re: JSL: Save report by group into tabs

From my experience, you will only get the tabs if you save window as an Interactive HTML.  In turn that requires the display not be saved from a journal, since journals do not have the Save Interactive HTML capability

Jim
Highlighted
JensRiege
Level III

Re: JSL: Save report by group into tabs

That did the trick. Did not see this explanation in the documentation.
Thank you for clarifying.
0 Kudos
Highlighted
ask
ask
Level I

Re: JSL: Save report by group into tabs

After running the script, i can not find analysis output in Tab2. Can you let me know why? Thanks.

0 Kudos
Highlighted

Re: JSL: Save report by group into tabs

When you create a By() group, JMP is creating a set of subset tables for you automatically.  You can also do this on a level-by-level basis by using Where() clauses instead.

 

Here is a script that creates tabs per level, and as a bonus they are moveable and dockable, so they behave like a JMP Dashboard and can be rearranged in a variety of ways.

 

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

//get the unique levels
Summarize( dt, unique_values = by( :sex ) );

// Create the window with an empty tab list
nw = New Window( "Tabs", tb = Tab Box( <<Dockable( 1 ) ) );

// Generate tabs, one per level
For( i = 1, i <= N Items( unique_values ), i++,
	tb << Append(
		Tab Page Box(
			Title( ":sex = " || unique_values[i] ),
			dt << Bivariate( invisible, Y( :height ), X( :weight ), Where( :sex == unique_values[i] ) ),
			<<Moveable( 1 ),
			<<Closeable( 1 )
		)
	)
);
Highlighted
JPKO
Level III

Re: JSL: Save report by group into tabs

Thanks, both of you! Both solutions worked like a charm.

0 Kudos