<?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 Re: Subsetting Averages Based on IDs in multiple columns? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Subsetting-Averages-Based-on-IDs-in-multiple-columns/m-p/802826#M97946</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/47057"&gt;@Mcc99&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; There's a couple different ways to do this, but one of the easiest, might be using the Tabulate platform.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Using the sample data table that you provided, you can do it with just a little bit of JSL:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Tabulate(
	Add Table(
		Column Table( Analysis Columns( :Data A, :Data B ), Statistics( Mean ) ),
		Row Table( Grouping Columns( :Subject, :Group ) )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; The corresponding output from the Tabulate platform looks like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SDF1_0-1727723708818.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/68732i597FB2A6D7E4E403/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SDF1_0-1727723708818.png" alt="SDF1_0-1727723708818.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Which I believe is exactly what you're after. You can of course add more statistics to include or perform the Tabulate in other ways, but I believe this is what you want. You can then click Done and with the red hot button drop-down menu, you can select Make Into Data Table, and then get your data table from the platform (you can also use JSL to do all this for you).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; It looks like the previous post you referenced used a column formula instead, which was the other way I would have suggested, but it's already been answered there, so you can always review that post in more detail if that's the way you want to go. But, I really think the Tabulate platform is what you want -- and you can play around with the different grouping columns and so forth to see how the data changes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps!,&lt;/P&gt;
&lt;P&gt;DS&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 30 Sep 2024 19:20:07 GMT</pubDate>
    <dc:creator>SDF1</dc:creator>
    <dc:date>2024-09-30T19:20:07Z</dc:date>
    <item>
      <title>Subsetting Averages Based on IDs in multiple columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Subsetting-Averages-Based-on-IDs-in-multiple-columns/m-p/802800#M97944</link>
      <description>&lt;P&gt;I need a JSL script to take averages from multiple columns of data and subset them into a separate data table. However I need the averages to be grouped by multiple categorical identifiers. For example, for the data table below I would need the averages of SubjectA Group X, and Subject A Group y, as separate lines as shown in the second example table. Something similar to &lt;A href="https://community.jmp.com/t5/Discussions/Taking-column-average-based-on-some-condition-on-other-column/td-p/400116" target="_self"&gt;this previous question.&lt;/A&gt;&amp;nbsp; How would I modify the script to include averages for multiple columns? If I need to make the average columns in the source data table and then subset out separately that would work as well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example Source Table:&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Subject&lt;/TD&gt;&lt;TD&gt;Group&lt;/TD&gt;&lt;TD&gt;Data A&lt;/TD&gt;&lt;TD&gt;Data B&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&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D&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;z&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using JMP Pro 18 on Windows.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2024 18:24:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Subsetting-Averages-Based-on-IDs-in-multiple-columns/m-p/802800#M97944</guid>
      <dc:creator>Mcc99</dc:creator>
      <dc:date>2024-09-30T18:24:24Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting Averages Based on IDs in multiple columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Subsetting-Averages-Based-on-IDs-in-multiple-columns/m-p/802826#M97946</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/47057"&gt;@Mcc99&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; There's a couple different ways to do this, but one of the easiest, might be using the Tabulate platform.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Using the sample data table that you provided, you can do it with just a little bit of JSL:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Tabulate(
	Add Table(
		Column Table( Analysis Columns( :Data A, :Data B ), Statistics( Mean ) ),
		Row Table( Grouping Columns( :Subject, :Group ) )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; The corresponding output from the Tabulate platform looks like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SDF1_0-1727723708818.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/68732i597FB2A6D7E4E403/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SDF1_0-1727723708818.png" alt="SDF1_0-1727723708818.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Which I believe is exactly what you're after. You can of course add more statistics to include or perform the Tabulate in other ways, but I believe this is what you want. You can then click Done and with the red hot button drop-down menu, you can select Make Into Data Table, and then get your data table from the platform (you can also use JSL to do all this for you).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; It looks like the previous post you referenced used a column formula instead, which was the other way I would have suggested, but it's already been answered there, so you can always review that post in more detail if that's the way you want to go. But, I really think the Tabulate platform is what you want -- and you can play around with the different grouping columns and so forth to see how the data changes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps!,&lt;/P&gt;
&lt;P&gt;DS&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2024 19:20:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Subsetting-Averages-Based-on-IDs-in-multiple-columns/m-p/802826#M97946</guid>
      <dc:creator>SDF1</dc:creator>
      <dc:date>2024-09-30T19:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting Averages Based on IDs in multiple columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Subsetting-Averages-Based-on-IDs-in-multiple-columns/m-p/802834#M97949</link>
      <description>&lt;P&gt;Thanks! I didn't even think to use tabulate but it makes my script much cleaner than the column formula. However, I'm having trouble saving the tabulate table as a new data table. I added the script below, after the tabulate script above. Although the tabulate window opens the new data table doesn't.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;&amp;lt;&amp;lt; Make Into Data Table(Outputtable("Average data"));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Sep 2024 20:27:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Subsetting-Averages-Based-on-IDs-in-multiple-columns/m-p/802834#M97949</guid>
      <dc:creator>Mcc99</dc:creator>
      <dc:date>2024-09-30T20:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting Averages Based on IDs in multiple columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Subsetting-Averages-Based-on-IDs-in-multiple-columns/m-p/802924#M97964</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/47057"&gt;@Mcc99&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another option you could consider is using Table &amp;gt; Summary. The Preview pane helps make sure you have the correct output, especially when you are grouping by multiple columns.&lt;BR /&gt;&lt;BR /&gt;Tables &amp;gt; Summary:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="scott_allen_0-1727783943223.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/68745iF54C40DE37F35DA6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="scott_allen_0-1727783943223.png" alt="scott_allen_0-1727783943223.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Source Script:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Data Table( "Data Table Name" ) &amp;lt;&amp;lt; Summary(
	Group( :Subject, :Group ),
	Mean( :Data A ),
	Mean( :Data B ),
	Freq( "None" ),
	Weight( "None" ),
	output table name( "Summary of Data Table Name by Subject, Group" )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 12:04:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Subsetting-Averages-Based-on-IDs-in-multiple-columns/m-p/802924#M97964</guid>
      <dc:creator>scott_allen</dc:creator>
      <dc:date>2024-10-01T12:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting Averages Based on IDs in multiple columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Subsetting-Averages-Based-on-IDs-in-multiple-columns/m-p/802959#M97970</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/47057"&gt;@Mcc99&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Are you sure you're referencing your objects correctly in JSL?&amp;nbsp; If you use the below code (assuming you're working with the data table structure like in your example, it will generate the correct tabulated data table using Tabulate, then make it into a data table with the given name and also close the Tabulate window.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Current Data Table();

dttab = dt &amp;lt;&amp;lt; Tabulate(
	Add Table(
		Column Table( Analysis Columns( :Data A, :Data B ), Statistics( Mean ) ),
		Row Table( Grouping Columns( :Subject, :Group ) )
	)
);

dttab &amp;lt;&amp;lt; Make Into Data Table( OutputTable( "Average Data" ) );

dttab &amp;lt;&amp;lt;Close Window;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope this helps!,&lt;/P&gt;
&lt;P&gt;DS&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 15:19:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Subsetting-Averages-Based-on-IDs-in-multiple-columns/m-p/802959#M97970</guid>
      <dc:creator>SDF1</dc:creator>
      <dc:date>2024-10-01T15:19:28Z</dc:date>
    </item>
  </channel>
</rss>

