<?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: Script to create a summary table with filters in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Script-to-create-a-summary-table-with-filters/m-p/567200#M77821</link>
    <description>&lt;P&gt;By filtering do you mean you want to delete other rows? If this is the case:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using Big Class.jmp as example table. Leaving only rows with have :sex value of "M" to summary table&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
wait(1);
dt_summary = dt &amp;lt;&amp;lt; Summary(
	Group(:age, :sex),
	Mean(:height),
	Mean(:weight),
	Freq("None"),
	Weight("None"),
	Link to original data table(0)
);
wait(1);
dt_summary &amp;lt;&amp;lt; Delete Rows(dt_summary &amp;lt;&amp;lt; Get Rows Where(:sex != "M"));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Using tabulate might also be a good option. You can use local data filter or directly add Where (what I'm doing here)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
wait(1);

tab = dt &amp;lt;&amp;lt; Tabulate(
	Show Control Panel(0),
	Add Table(
		Column Table(Analysis Columns(:height, :weight), Statistics(Mean)),
		Row Table(Grouping Columns(:sex, :age))
	),
	Where(:sex == "M")
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Scripting index has quite good suggestions:&lt;/P&gt;
&lt;P&gt;Delete Rows:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1667985967698.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/47190i419F44D52CF5930C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1667985967698.png" alt="jthi_0-1667985967698.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Get Rows Where:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1667985983884.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/47191iE26775E72A02D16C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1667985983884.png" alt="jthi_1-1667985983884.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Select Where:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_2-1667986011793.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/47192iD26F79D1D29CA62F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_2-1667986011793.png" alt="jthi_2-1667986011793.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 09 Nov 2022 09:30:05 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2022-11-09T09:30:05Z</dc:date>
    <item>
      <title>Script to create a summary table with filters</title>
      <link>https://community.jmp.com/t5/Discussions/Script-to-create-a-summary-table-with-filters/m-p/567189#M77820</link>
      <description>&lt;P&gt;Hi all&lt;/P&gt;&lt;P&gt;I have a data table with some numerical columns (VAL1, VAL2) and some char columns (CATEG1, CATEG2, CATEG3).&lt;/P&gt;&lt;P&gt;I want to write a script to crete a summary table reporting the average value of each numerical value grouped by "CATEG1,23"; this easily done:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Data Table( "MyTable" ) &amp;lt;&amp;lt;
Summary(
Group(
:Lot,
:Name( "CATEG1" ),
:Name( "CATEG2" ),
:Name( "CATEG3" ),
),
Mean( :VAL1),
Mean( :VAL2),

Freq( "None" ),
Weight( "None" ),
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I'like also to filter the results according to CATEG1,2,3: e.g. to include only results with CATEG1=="Standard".&lt;/P&gt;&lt;P&gt;I tried brutally inserting a "where" clause, but it doesn't seem to wiork&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;  where(:CATEG1 == "Standard")&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I know that this can be easily done interactively, but I'd like to do it via script.&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EV1976&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:56:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-to-create-a-summary-table-with-filters/m-p/567189#M77820</guid>
      <dc:creator>EV1976</dc:creator>
      <dc:date>2023-06-10T23:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: Script to create a summary table with filters</title>
      <link>https://community.jmp.com/t5/Discussions/Script-to-create-a-summary-table-with-filters/m-p/567200#M77821</link>
      <description>&lt;P&gt;By filtering do you mean you want to delete other rows? If this is the case:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using Big Class.jmp as example table. Leaving only rows with have :sex value of "M" to summary table&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
wait(1);
dt_summary = dt &amp;lt;&amp;lt; Summary(
	Group(:age, :sex),
	Mean(:height),
	Mean(:weight),
	Freq("None"),
	Weight("None"),
	Link to original data table(0)
);
wait(1);
dt_summary &amp;lt;&amp;lt; Delete Rows(dt_summary &amp;lt;&amp;lt; Get Rows Where(:sex != "M"));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Using tabulate might also be a good option. You can use local data filter or directly add Where (what I'm doing here)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
wait(1);

tab = dt &amp;lt;&amp;lt; Tabulate(
	Show Control Panel(0),
	Add Table(
		Column Table(Analysis Columns(:height, :weight), Statistics(Mean)),
		Row Table(Grouping Columns(:sex, :age))
	),
	Where(:sex == "M")
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Scripting index has quite good suggestions:&lt;/P&gt;
&lt;P&gt;Delete Rows:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1667985967698.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/47190i419F44D52CF5930C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1667985967698.png" alt="jthi_0-1667985967698.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Get Rows Where:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1667985983884.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/47191iE26775E72A02D16C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1667985983884.png" alt="jthi_1-1667985983884.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Select Where:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_2-1667986011793.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/47192iD26F79D1D29CA62F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_2-1667986011793.png" alt="jthi_2-1667986011793.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 09:30:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-to-create-a-summary-table-with-filters/m-p/567200#M77821</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-11-09T09:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: Script to create a summary table with filters</title>
      <link>https://community.jmp.com/t5/Discussions/Script-to-create-a-summary-table-with-filters/m-p/567225#M77825</link>
      <description>&lt;P&gt;Both solutions work for me.&lt;BR /&gt;"Tabulate" option suits perfectly my needs&lt;/P&gt;&lt;P&gt;Thank you very much&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EV1976&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 10:11:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-to-create-a-summary-table-with-filters/m-p/567225#M77825</guid>
      <dc:creator>EV1976</dc:creator>
      <dc:date>2022-11-09T10:11:01Z</dc:date>
    </item>
  </channel>
</rss>

