<?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 use jsl to calculate standard deviation by ID in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/how-to-use-jsl-to-calculate-standard-deviation-by-ID/m-p/767115#M94734</link>
    <description>&lt;P&gt;Hi, I have a table similar to this, and I wanted to select IDs where there are more than one entry and calculate standard deviation of the result grouped by ID. For example, in this case, I need to select ID 12345 and calculate standard deviation of the first 3 results.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know I can do this by tabulate, but my actual table is very big, more than 1 million rows, tabulate by ID and calculate standard deviation turns out to be extremely time consuming. Most IDs in my actual table have only one row. Is there anyway I can do something like this and then calculate standard deviation for the remaining results group by ID? Thank you for your suggestion!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; select where(n rows(grouping columns (:ID))&amp;gt;1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;result&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12345&lt;/TD&gt;&lt;TD&gt;0.3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12345&lt;/TD&gt;&lt;TD&gt;0.4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12345&lt;/TD&gt;&lt;TD&gt;0.2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;23456&lt;/TD&gt;&lt;TD&gt;0.5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;34567&lt;/TD&gt;&lt;TD&gt;0.2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
    <pubDate>Wed, 19 Jun 2024 18:41:27 GMT</pubDate>
    <dc:creator>emmablue</dc:creator>
    <dc:date>2024-06-19T18:41:27Z</dc:date>
    <item>
      <title>how to use jsl to calculate standard deviation by ID</title>
      <link>https://community.jmp.com/t5/Discussions/how-to-use-jsl-to-calculate-standard-deviation-by-ID/m-p/767115#M94734</link>
      <description>&lt;P&gt;Hi, I have a table similar to this, and I wanted to select IDs where there are more than one entry and calculate standard deviation of the result grouped by ID. For example, in this case, I need to select ID 12345 and calculate standard deviation of the first 3 results.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know I can do this by tabulate, but my actual table is very big, more than 1 million rows, tabulate by ID and calculate standard deviation turns out to be extremely time consuming. Most IDs in my actual table have only one row. Is there anyway I can do something like this and then calculate standard deviation for the remaining results group by ID? Thank you for your suggestion!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; select where(n rows(grouping columns (:ID))&amp;gt;1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;result&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12345&lt;/TD&gt;&lt;TD&gt;0.3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12345&lt;/TD&gt;&lt;TD&gt;0.4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12345&lt;/TD&gt;&lt;TD&gt;0.2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;23456&lt;/TD&gt;&lt;TD&gt;0.5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;34567&lt;/TD&gt;&lt;TD&gt;0.2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 19 Jun 2024 18:41:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/how-to-use-jsl-to-calculate-standard-deviation-by-ID/m-p/767115#M94734</guid>
      <dc:creator>emmablue</dc:creator>
      <dc:date>2024-06-19T18:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to use jsl to calculate standard deviation by ID</title>
      <link>https://community.jmp.com/t5/Discussions/how-to-use-jsl-to-calculate-standard-deviation-by-ID/m-p/767129#M94735</link>
      <description>&lt;P&gt;Select your grouping column (ID)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1718823059761.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/65422iB43D93B93AC8CB63/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1718823059761.png" alt="jthi_0-1718823059761.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Then select the column you wish to perform the calculation on and pick Standard Deviation (note the Grouping by id)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1718823097679.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/65423i4AACE6409C913685/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1718823097679.png" alt="jthi_1-1718823097679.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_2-1718823115628.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/65424i917CE51E3AF276A0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_2-1718823115628.png" alt="jthi_2-1718823115628.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_3-1718823145121.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/65425i262D252E48359758/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_3-1718823145121.png" alt="jthi_3-1718823145121.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 05:30:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/how-to-use-jsl-to-calculate-standard-deviation-by-ID/m-p/767129#M94735</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-06-20T05:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to use jsl to calculate standard deviation by ID</title>
      <link>https://community.jmp.com/t5/Discussions/how-to-use-jsl-to-calculate-standard-deviation-by-ID/m-p/767237#M94741</link>
      <description>&lt;P&gt;Few more options&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create summary table&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_5-1718861375094.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/65438i981BB6FADB16BD42/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_5-1718861375094.png" alt="jthi_5-1718861375094.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After you have the summary table, you can click on the stddev column and hold mouse down for some time. This allows you to "pick" the column and drop it to your original table&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_6-1718861375055.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/65440i17A81D90377AE5DF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_6-1718861375055.png" alt="jthi_6-1718861375055.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could also have used Update with the summary table&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_7-1718861374827.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/65439i9E69B7F9E1AF6FF6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_7-1718861374827.png" alt="jthi_7-1718861374827.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create similar table using Tabulate (note that id is nominal)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_8-1718861374816.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/65441i9AAC52B9D5D74F2F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_8-1718861374816.png" alt="jthi_8-1718861374816.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then from red triangle, make into data table&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_9-1718861374826.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/65442iA31FF03AD6FE4CD9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_9-1718861374826.png" alt="jthi_9-1718861374826.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you can then use Update (or join) to get the results back to your table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are also many scripting options, here is one using &lt;A href="https://www.jmp.com/support/help/en/17.2/#page/jmp/statistical-functions-2.shtml?os=win&amp;amp;source=application#ww4981217" target="_self" rel="noopener noreferrer"&gt;Summarize()&lt;/A&gt;&amp;nbsp;&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();

Summarize(ids = by(:ID), stddevs = Std dev(:result));
show(ids, stddevs); 
// ids = {"12345", "23456", "34567"}; // note that these are strings even if they were numbers originally
// stddevs = [0.1, ., .];
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 05:29:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/how-to-use-jsl-to-calculate-standard-deviation-by-ID/m-p/767237#M94741</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-06-20T05:29:46Z</dc:date>
    </item>
  </channel>
</rss>

