<?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: Pre-evaluated Statistics (Col Mean, Col Median) in Loop in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Pre-evaluated-Statistics-Col-Mean-Col-Median-in-Loop/m-p/512462#M74001</link>
    <description>&lt;P&gt;The reason for performing the calculations this way is I would like to feed the result to a script that separately plots the data in each column and uses the calculated values for upper and lower plotting limits.&lt;/P&gt;</description>
    <pubDate>Wed, 22 Jun 2022 17:05:27 GMT</pubDate>
    <dc:creator>TheCakeIsALie</dc:creator>
    <dc:date>2022-06-22T17:05:27Z</dc:date>
    <item>
      <title>Pre-evaluated Statistics (Col Mean, Col Median) in Loop</title>
      <link>https://community.jmp.com/t5/Discussions/Pre-evaluated-Statistics-Col-Mean-Col-Median-in-Loop/m-p/512419#M73997</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to calculate the mean and median of the standard deviation by group for multiple columns in JSL. The data table I'm using is shown below and attached. I have verified the correct calculations in the columns to the right of the values but the JSL output does not match exactly. The code below correctly calculates the mean of the standard deviation by group for both values, but the median only calculates correctly for the first value; the result for the median of the second value is exactly the same as what was calculated for the first value. I cannot figure out why the mean values update correctly in the loop but not the median values. Any help on this is appreciated and please let me know what the best method in JSL is to do this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TheCakeIsALie_0-1655913183403.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/43474i171C6368F88F9861/image-size/medium?v=v2&amp;amp;px=400" role="button" title="TheCakeIsALie_0-1655913183403.png" alt="TheCakeIsALie_0-1655913183403.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;JSL:&lt;/P&gt;&lt;PRE&gt;For( i = 2, i &amp;lt; 4, i++,
	N = Column Name( i );
	Print( "i = " || Char( i ) );
	Print( "Column Name = " || Char( Column Name( i ) ) );
	Print( "Column Mean Std Dev by Group = " || Char( Col Mean( Col Std Dev( N, :Group ) ) ) );
	Print( "Column Median Std Dev by Group = " || Char( Col Median( Col Std Dev( N, :Group ) ) ) );
);&lt;/PRE&gt;&lt;P&gt;JSL Output:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;"i = 2"
"Column Name = Value 1"
"Column Mean Std Dev by Group = 3.9849040980727"
"Column Median Std Dev by Group = 3.60555127546399"
"i = 3"
"Column Name = Value 2"
"Column Mean Std Dev by Group = 5.14008843607314"
"Column Median Std Dev by Group = 3.60555127546399"&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;JMP Pro v16&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 17:02:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Pre-evaluated-Statistics-Col-Mean-Col-Median-in-Loop/m-p/512419#M73997</guid>
      <dc:creator>TheCakeIsALie</dc:creator>
      <dc:date>2023-06-09T17:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: Pre-evaluated Statistics (Col Mean, Col Median) in Loop</title>
      <link>https://community.jmp.com/t5/Discussions/Pre-evaluated-Statistics-Col-Mean-Col-Median-in-Loop/m-p/512443#M73999</link>
      <description>&lt;P&gt;Is there a reason to perform calculations like this with looping and with formulas? JMP does provide you with Summary (table), Summarize and Tabulate which might be better options depending on what you are trying to do. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For looping, I'm not sure if you can really (or if you should) loop Col functions like while using byVar that as they will get evaluated a bit weirdly.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1655916126101.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/43477iCE3CC2313FEB81A4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1655916126101.png" alt="jthi_0-1655916126101.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 16:42:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Pre-evaluated-Statistics-Col-Mean-Col-Median-in-Loop/m-p/512443#M73999</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-06-22T16:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Pre-evaluated Statistics (Col Mean, Col Median) in Loop</title>
      <link>https://community.jmp.com/t5/Discussions/Pre-evaluated-Statistics-Col-Mean-Col-Median-in-Loop/m-p/512462#M74001</link>
      <description>&lt;P&gt;The reason for performing the calculations this way is I would like to feed the result to a script that separately plots the data in each column and uses the calculated values for upper and lower plotting limits.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 17:05:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Pre-evaluated-Statistics-Col-Mean-Col-Median-in-Loop/m-p/512462#M74001</guid>
      <dc:creator>TheCakeIsALie</dc:creator>
      <dc:date>2022-06-22T17:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: Pre-evaluated Statistics (Col Mean, Col Median) in Loop</title>
      <link>https://community.jmp.com/t5/Discussions/Pre-evaluated-Statistics-Col-Mean-Col-Median-in-Loop/m-p/512469#M74002</link>
      <description>&lt;P&gt;Summarize should work fairly nicely here:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Current Data Table();

Summarize(dt, groups = By(:Group), v1_std = StdDev(:Value 1), v2_std = StdDev(:Value 2));
Show(groups, v1_std, v2_std);
Show(Mean(v1_std));
Show(Mean(v2_std));
Show(Median(v1_std));
Show(Median(v2_std));&lt;BR /&gt;&lt;BR /&gt;/*groups = {"A", "B", "C", "D"};&lt;BR /&gt;v1_std = [3.60555127546399, 2.64575131106459, 3.60555127546399, 6.08276253029822];&lt;BR /&gt;v2_std = [7.23417813807024, 8.9628864398325, 0.577350269189626, 3.78593889720018];&lt;BR /&gt;Mean(v1_std) = 3.9849040980727;&lt;BR /&gt;Mean(v2_std) = 5.14008843607314;&lt;BR /&gt;Median(v1_std) = 3.60555127546399;&lt;BR /&gt;Median(v2_std) = 5.51005851763521;*/&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Jun 2022 17:21:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Pre-evaluated-Statistics-Col-Mean-Col-Median-in-Loop/m-p/512469#M74002</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-06-22T17:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: Pre-evaluated Statistics (Col Mean, Col Median) in Loop</title>
      <link>https://community.jmp.com/t5/Discussions/Pre-evaluated-Statistics-Col-Mean-Col-Median-in-Loop/m-p/512501#M74003</link>
      <description>&lt;P&gt;I agree, this looks like the correct way to handle this. However, it relies on typing out all the column names. Is there a way to generalize it for many columns without knowing the column name? This was the main reason to use the For loop in my code.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 18:30:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Pre-evaluated-Statistics-Col-Mean-Col-Median-in-Loop/m-p/512501#M74003</guid>
      <dc:creator>TheCakeIsALie</dc:creator>
      <dc:date>2022-06-22T18:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: Pre-evaluated Statistics (Col Mean, Col Median) in Loop</title>
      <link>https://community.jmp.com/t5/Discussions/Pre-evaluated-Statistics-Col-Mean-Col-Median-in-Loop/m-p/512510#M74005</link>
      <description>&lt;P&gt;You could still loop it, but use Summarize instead of functions Col functions which might not work with the byVar. This is one option:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Current Data Table();

col_list = {"Value 1", "Value 2"};

For Each({col_name}, col_list,
	Summarize(dt, groups = By(:Group), v_std = StdDev(Eval(col_name)));
	Show(col_name, v_std);
	Show(Mean(v_std));
	Show(Median(v_std));	
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is other option with Summary table could be used (two ways for calculations) :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Current Data Table();

col_list = {"Value 1", "Value 2"};
dt_summary = dt &amp;lt;&amp;lt; Summary(
	Group(:Group),
	Std Dev(EvalList({col_list})),
	Freq("None"),
	Weight("None"),
	statistics column name format("column"),
	Link to original data table(0),
	invisible
);
For Each({col_name}, col_list,
	mea = Mean(dt_summary[0, col_name]);
	med = Median(dt_summary[0, col_name]);
	// or
	mea1 = Col Mean(As Column(col_name));
	med1 = Col Median(As Column(col_name));
	Show(col_name, mea, med, mea1, med1);
);
Close(dt_summary, no save);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 18:44:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Pre-evaluated-Statistics-Col-Mean-Col-Median-in-Loop/m-p/512510#M74005</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-06-22T18:44:39Z</dc:date>
    </item>
  </channel>
</rss>

