<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to create subcategories for rows and columns similar to tabulate in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-create-subcategories-for-rows-and-columns-similar-to/m-p/477114#M72157</link>
    <description>&lt;P&gt;I'm currently working on creating a data table of results from a SQL query. The final data table has a set up that merges the shared column groups and merges the rows of shared values as well (see Table 1).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data sometimes has numeric values, but most of the results are strings like "Negative" or "&amp;lt; 0.1". The way I summarize the data table with the character/nominal values is by transposing the results based on the type of test. I can group the columns, but when I send the data table to a new window as a report or to a journal page, it doesn't display the grouped columns. I can't use Tabulate because it only summarizes numeric values and it also won't allow you to keep the formatting when you make it into a data table. I also can't color the cells within a Tabulate table. I just want the ability to add subcategories and nested columns/rows like tabulate does to a regular data table. I'm wondering if there's any way to achieve what I'm looking for within JMP using JSL code, and if there isn't, can this be a feature request?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table 1. Example of Final Table&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="svarga_0-1649360304997.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/41592iDE92B4A8E9E3F7CE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="svarga_0-1649360304997.png" alt="svarga_0-1649360304997.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 10 Jun 2023 23:46:54 GMT</pubDate>
    <dc:creator>svarga</dc:creator>
    <dc:date>2023-06-10T23:46:54Z</dc:date>
    <item>
      <title>How to create subcategories for rows and columns similar to tabulate</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-create-subcategories-for-rows-and-columns-similar-to/m-p/477114#M72157</link>
      <description>&lt;P&gt;I'm currently working on creating a data table of results from a SQL query. The final data table has a set up that merges the shared column groups and merges the rows of shared values as well (see Table 1).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data sometimes has numeric values, but most of the results are strings like "Negative" or "&amp;lt; 0.1". The way I summarize the data table with the character/nominal values is by transposing the results based on the type of test. I can group the columns, but when I send the data table to a new window as a report or to a journal page, it doesn't display the grouped columns. I can't use Tabulate because it only summarizes numeric values and it also won't allow you to keep the formatting when you make it into a data table. I also can't color the cells within a Tabulate table. I just want the ability to add subcategories and nested columns/rows like tabulate does to a regular data table. I'm wondering if there's any way to achieve what I'm looking for within JMP using JSL code, and if there isn't, can this be a feature request?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table 1. Example of Final Table&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="svarga_0-1649360304997.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/41592iDE92B4A8E9E3F7CE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="svarga_0-1649360304997.png" alt="svarga_0-1649360304997.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:46:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-create-subcategories-for-rows-and-columns-similar-to/m-p/477114#M72157</guid>
      <dc:creator>svarga</dc:creator>
      <dc:date>2023-06-10T23:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to create subcategories for rows and columns similar to tabulate</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-create-subcategories-for-rows-and-columns-similar-to/m-p/477240#M72163</link>
      <description>&lt;P&gt;JMP does not allow you to group rows.&amp;nbsp; Tabulate does not group rows, it simply leaves some rows blank (see below).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you look at the tree structure for Tabulate then you'll notice that JMP uses special constructs such as &lt;CODE class=" language-jsl"&gt;MultiTblStrColBox&lt;/CODE&gt; and&amp;nbsp;&lt;CODE class=" language-jsl"&gt;MultiTblNumColBox&lt;/CODE&gt; to create the tabulate's table.&amp;nbsp; These are not something that can be created in JSL by the user.&amp;nbsp; The next best thing is to utilize the &lt;CODE class=" language-jsl"&gt;&amp;lt;&amp;lt;Get As Report&lt;/CODE&gt; with some fancy group and name handling to create something similar with &lt;CODE class=" language-jsl"&gt;TableBox&lt;/CODE&gt; -- which we do have access to in JSL.&amp;nbsp; Here is a quick function "&lt;CODE class=" language-jsl"&gt;tabulatish&lt;/CODE&gt;" that I threw together that can take a table that has specified colors on it's cells with any column grouping you may desire and creates something like tabulate.&amp;nbsp; You do need to specifiy a table and special categorical column within:&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ErraticAttach_5-1649381797415.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/41601iD91ACA18B9131247/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ErraticAttach_5-1649381797415.png" alt="ErraticAttach_5-1649381797415.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
table = Open( "$SAMPLE_DATA/Blood Pressure.jmp" );
theGroup = table &amp;lt;&amp;lt; Group Columns( "BP", :BP 8M :: :BP 8W );
theGroup = table &amp;lt;&amp;lt; Group Columns( "ELSE", {:BP 12W, :BP 6W} );
For( i = 1, i &amp;lt;= N Cols( table ), i++,
	For Each Row( table,
		Column( table, i ) &amp;lt;&amp;lt; Color Cells( Eval List( Repeat( {Random Uniform( 0.9, 1 )}, 3 ) ), Row() )
	);
);

tabulatish = Function( {table, category},
	{Default Local},
	column names = table &amp;lt;&amp;lt; Get Column Names( "String" );
	For( i = 1, i &amp;lt;= N Items( column names ), i++,
		If( Uppercase( category ) == Uppercase( column names[i] ),
			category = column names[i];
			Break();
		)
	);
	Eval( Parse( Eval Insert( JSL Quote(
	table &amp;lt;&amp;lt; Sort( By( :Name("^category^") ), Order( "Ascending" ), "Replace Table" );
	) ) ) );

	categories = Associative Array( Column( table, category ) ) &amp;lt;&amp;lt; Get Keys;
	locs = Repeat( {""}, N Rows( table ) );
	For( i = 1, i &amp;lt;= N Items( categories ), i++,
		locs[(Loc( Column( table, category ) &amp;lt;&amp;lt; Get Values, categories[i] ))[1]] = categories[i]
	);
	
	nt = New Table( "temp", &amp;lt;&amp;lt;New Column( category, "Character", &amp;lt;&amp;lt;Set Values( locs ) ), Private );
	olb = Outline Box( "",
		nt &amp;lt;&amp;lt; Get As Report
	);
	Close( nt, No Save );
	
	group names = table &amp;lt;&amp;lt; Get Column Groups Names();
	groups = {};
	For( i = 1, i &amp;lt;= N Items( group names ), i++,
		Insert Into( groups, table &amp;lt;&amp;lt; Get Column Group( group names[i] ) )
	);
	For( i = 1, i &amp;lt;= N Items( groups ), i++,
		groups[i] = Char( groups[i] )
	);
	
	Remove From( column names, Contains( column names, category ) );

	While( 1,
		cols = {};
		Insert Into( cols, column names[1] );
		If( Contains( groups, column names[1] ),
			For( i = 1, i &amp;lt;= N Items( group names ), i++,
				names = table &amp;lt;&amp;lt; Get Column Group( group names[i] );
				For( j = 1, j &amp;lt;= N Items( names ), j++,
					names[j] = Char( names[j] )
				);
				If( Contains( names, column names[1] ),
					cols = names;
					Break();
				)
			)
		);
		t = table &amp;lt;&amp;lt; Subset(  All Rows, Columns( cols ), Not Linked, Private );
		report = t &amp;lt;&amp;lt; Get As Report;
		If( N Items( cols ) == 1,
			olb[Table Box( 1 )] &amp;lt;&amp;lt; Append( Try( report[String Col Box( 1 )], report[Number Col Box( 1 )] ) );
		,
			span box = Col Span Box( group names[i] );
			For( i = 1, i &amp;lt;= N Items( cols ), i++,
				span box &amp;lt;&amp;lt; Append( Try( report[String Col Box( i )], report[Number Col Box( i )] ) )
			);
			olb[Table Box( 1 )] &amp;lt;&amp;lt; Append( span box )
		);
		Close( t, No Save );
		column names = Associative Array( column names );
		column names &amp;lt;&amp;lt; Remove( Associative Array( cols ) );
		column names = column names &amp;lt;&amp;lt; Get Keys;
		If( N Items( column names ) == 0, Break() );
	);
	olb[Table Box( 1 )] &amp;lt;&amp;lt; Set Scrollable( 30, N Cols( table ) + 25 ) &amp;lt;&amp;lt; Set Shade Alternate Rows( 0 );
	olb
);

New Window( "Test",
	tabulatish( table, "dose" )
);

Close( table, No Save );&lt;/CODE&gt;&lt;/PRE&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ErraticAttach_3-1649381445297.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/41599iCCE78E5F59418C66/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ErraticAttach_3-1649381445297.png" alt="ErraticAttach_3-1649381445297.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 01:42:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-create-subcategories-for-rows-and-columns-similar-to/m-p/477240#M72163</guid>
      <dc:creator>ErraticAttack</dc:creator>
      <dc:date>2022-04-08T01:42:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to create subcategories for rows and columns similar to tabulate</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-create-subcategories-for-rows-and-columns-similar-to/m-p/477242#M72165</link>
      <description>&lt;P&gt;This looks very promising!! Thank you! I'll let you know if it works.&lt;/P&gt;&lt;P&gt;Edit: Spent the morning going through your code. It's a great start for me to figure out how to build more custom tables. Thank you! I appreciate the time and effort. Is there a way to add a span box above the columns to an already existing table? For example, let's say I organized the table without the extra categorization. I don't want to go column by column to piece together the table. I just want to pop it up above. Hope that makes sense.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 16:04:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-create-subcategories-for-rows-and-columns-similar-to/m-p/477242#M72165</guid>
      <dc:creator>svarga</dc:creator>
      <dc:date>2022-04-08T16:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to create subcategories for rows and columns similar to tabulate</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-create-subcategories-for-rows-and-columns-similar-to/m-p/477551#M72183</link>
      <description>&lt;P&gt;I don't think you'd be able to do that very easily.&amp;nbsp; Due to the hierarchical nature of the display tree you can't simply insert a display box such that objects that weren't its children then become its children.&amp;nbsp; You could insert a &lt;CODE class=" language-jsl"&gt;ColSpanBox&lt;/CODE&gt;, then using &lt;CODE class=" language-jsl"&gt;&amp;lt;&amp;lt;CloneBox&lt;/CODE&gt; you could insert children into the &lt;CODE class=" language-jsl"&gt;ColSpanBox&lt;/CODE&gt;, but at that point you'd be better off just creating it from scratch&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ErraticAttach_0-1649437153713.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/41613i5269B1551C321D50/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ErraticAttach_0-1649437153713.png" alt="ErraticAttach_0-1649437153713.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 17:01:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-create-subcategories-for-rows-and-columns-similar-to/m-p/477551#M72183</guid>
      <dc:creator>ErraticAttack</dc:creator>
      <dc:date>2022-04-08T17:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to create subcategories for rows and columns similar to tabulate</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-create-subcategories-for-rows-and-columns-similar-to/m-p/477581#M72186</link>
      <description>&lt;P&gt;That's what I thought but figured I'd ask. Thanks again for the help!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 18:08:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-create-subcategories-for-rows-and-columns-similar-to/m-p/477581#M72186</guid>
      <dc:creator>svarga</dc:creator>
      <dc:date>2022-04-08T18:08:01Z</dc:date>
    </item>
  </channel>
</rss>

