<?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 PROC SHEWHART pchart weight of subgroups with varying sizes in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/PROC-SHEWHART-pchart-weight-of-subgroups-with-varying-sizes/m-p/928146#M46214</link>
    <description>&lt;P&gt;I'm making a pChart using PROC SHEWHART, and my subgroups (lots) have varying sizes.&amp;nbsp; I want to give each lot the same weight when calculating pbar, rather than let lots with larger sample sizes have more weight.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I assumed PROC SHEWHART would have a WEIGHT statement, but it does not.&amp;nbsp; My next thought is to calculate pbar myself, and then pass the value to SHEWHART via the p0 option on the pchart statement.&amp;nbsp; Does this seem like a reasonable approach?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As an example, given data like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input lot pfailed ntested ;
  cards ;
1  .1 20
2  .2 20
3  .1 20
4  .2 20
5  .4 60
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PROC SHEWHART will calculate pbar as a weighted mean of the proportions, giving lot 5 more weight than the other lots, and you get pbar=.26.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc shewhart data=have ;
  pchart pfailed*lot/subgroupn=ntested dataunit=proportion;
run ; 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;My thought is to calculate pbar myself as the unweighted mean, and you get pbar=.2, and pass that value to PROC SHEWHART:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select mean(pfailed) into :pbar trimmed
  from have
  ;
quit ;

%put &amp;amp;=pbar ;

proc shewhart data=have ;
  pchart pfailed*lot/subgroupn=ntested dataunit=proportion p0=&amp;amp;pbar;
run ; 

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 13 May 2024 14:57:04 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2024-05-13T14:57:04Z</dc:date>
    <item>
      <title>PROC SHEWHART pchart weight of subgroups with varying sizes</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/PROC-SHEWHART-pchart-weight-of-subgroups-with-varying-sizes/m-p/928146#M46214</link>
      <description>&lt;P&gt;I'm making a pChart using PROC SHEWHART, and my subgroups (lots) have varying sizes.&amp;nbsp; I want to give each lot the same weight when calculating pbar, rather than let lots with larger sample sizes have more weight.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I assumed PROC SHEWHART would have a WEIGHT statement, but it does not.&amp;nbsp; My next thought is to calculate pbar myself, and then pass the value to SHEWHART via the p0 option on the pchart statement.&amp;nbsp; Does this seem like a reasonable approach?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As an example, given data like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input lot pfailed ntested ;
  cards ;
1  .1 20
2  .2 20
3  .1 20
4  .2 20
5  .4 60
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PROC SHEWHART will calculate pbar as a weighted mean of the proportions, giving lot 5 more weight than the other lots, and you get pbar=.26.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc shewhart data=have ;
  pchart pfailed*lot/subgroupn=ntested dataunit=proportion;
run ; 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;My thought is to calculate pbar myself as the unweighted mean, and you get pbar=.2, and pass that value to PROC SHEWHART:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select mean(pfailed) into :pbar trimmed
  from have
  ;
quit ;

%put &amp;amp;=pbar ;

proc shewhart data=have ;
  pchart pfailed*lot/subgroupn=ntested dataunit=proportion p0=&amp;amp;pbar;
run ; 

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2024 14:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/PROC-SHEWHART-pchart-weight-of-subgroups-with-varying-sizes/m-p/928146#M46214</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-05-13T14:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SHEWHART pchart weight of subgroups with varying sizes</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/PROC-SHEWHART-pchart-weight-of-subgroups-with-varying-sizes/m-p/928169#M46217</link>
      <description>&lt;H5&gt;I don't know if I would consider the default pbar as a weighted average in PROC SHEWHART.&amp;nbsp;&lt;/H5&gt;
&lt;H5&gt;data have ;&lt;BR /&gt;&amp;nbsp; input lot pfailed ntested;&lt;BR /&gt;&amp;nbsp; nfailed=pfailed*ntested;&lt;BR /&gt;cards ;&lt;BR /&gt;1 .1 20&lt;BR /&gt;2 .2 20&lt;BR /&gt;3 .1 20&lt;BR /&gt;4 .2 20&lt;BR /&gt;5 .4 60&lt;BR /&gt;;&lt;BR /&gt;proc print;&lt;BR /&gt;&amp;nbsp; sum pfailed ntested nfailed;&lt;BR /&gt;run;&lt;/H5&gt;
&lt;H5&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Zard_0-1715618343041.png" style="width: 200px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96486i2CC64E37C4670C5C/image-size/small?v=v2&amp;amp;px=200" role="button" title="Zard_0-1715618343041.png" alt="Zard_0-1715618343041.png" /&gt;&lt;/span&gt;&lt;/H5&gt;
&lt;H5&gt;pbar = 36/140=0.257, so just the average proportion failed.&lt;/H5&gt;
&lt;H5&gt;If you want the control limits computed using the same subgroup sample size, you could do&lt;/H5&gt;
&lt;H5&gt;proc shewhart data=have ;&lt;BR /&gt;&amp;nbsp; pchart pfailed*lot/subgroupn=20 dataunit=proportion;&lt;BR /&gt;run ;&lt;/H5&gt;
&lt;H5&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Zard_1-1715618544886.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96487iE22380843C5390C9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Zard_1-1715618544886.png" alt="Zard_1-1715618544886.png" /&gt;&lt;/span&gt;&lt;/H5&gt;
&lt;P&gt;Now the control limits are constant because the subgroup sample sizes are constant. If you ignore the subgroup sample sizes, the varying control limits are not correct.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2024 16:47:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/PROC-SHEWHART-pchart-weight-of-subgroups-with-varying-sizes/m-p/928169#M46217</guid>
      <dc:creator>Zard</dc:creator>
      <dc:date>2024-05-13T16:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SHEWHART pchart weight of subgroups with varying sizes</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/PROC-SHEWHART-pchart-weight-of-subgroups-with-varying-sizes/m-p/928176#M46218</link>
      <description>&lt;P&gt;It's weighted in the sense that a subgroup with larger number of items will contribute more to the estimate of pbar.&amp;nbsp; At least that is my understanding of:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Quentin_0-1715620479829.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96488i1CAA92C33561FA4F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Quentin_0-1715620479829.png" alt="Quentin_0-1715620479829.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I see the proportion for each subgroup being weighted by the number of items in the subgroup.&amp;nbsp; I would see an unweighted estimate of pbar as just the average of the proportions, i.e.:&amp;nbsp; (p_1+...+p_N)/N.&lt;BR /&gt;&lt;BR /&gt;I don't want to use subgroupN, because that would exclude lot 5 from contributing to the calculation of the control limits.&lt;BR /&gt;&lt;BR /&gt;In my general SPC reading when they show examples with varying size to the subgroups, typically there is little variation, and I think the assumption is that the size of a subgroup is uninformative.&amp;nbsp; In that setting, a larger sample size probably should get more weight, because it provides a better estimate.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;But for my example, the data collection process typically samples ~20 items.&amp;nbsp; If they find evidence of an increased rate for a subgroup, they sample 40 more items from that subgroup.&amp;nbsp; So you have some subgroups with 3x the size of other subgroups, and typically they are also the subgroups with an unusual value for the proportion (uncontrolled process).&amp;nbsp; I don't want to give these subgroups more weight than the others in calculating pbar.&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2024 17:27:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/PROC-SHEWHART-pchart-weight-of-subgroups-with-varying-sizes/m-p/928176#M46218</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-05-13T17:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SHEWHART pchart weight of subgroups with varying sizes</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/PROC-SHEWHART-pchart-weight-of-subgroups-with-varying-sizes/m-p/928186#M46219</link>
      <description>&lt;H6&gt;&lt;SPAN&gt;If you were computing the average percent, you would sum the percentages and divide by N to get (.1+.2+.1+.2+.4)/5=0.2 . But here we are averaging proportions and the sample size should technically not be ignored.&lt;/SPAN&gt;&lt;/H6&gt;
&lt;H5&gt;&lt;SPAN&gt;&amp;gt; I don't want to use subgroupN, because that would exclude lot 5 from contributing to the calculation of the control limits.&lt;/SPAN&gt;&lt;/H5&gt;
&lt;H6&gt;&lt;SPAN&gt;The SUBGROUPN option specifies the &lt;EM&gt;n_i&amp;nbsp;&lt;/EM&gt; values to use in computing pbar.&amp;nbsp; This allows for the case you describe, where you want all proportions to have equal weight, in that sense. Lot 5 is not excluded by SUBBGOUPN=20. Its contribution in the numerator becomes 20*.4 instead of 60*.4, and it gives you the pbar you want. This is how PROC SHEWHART lets you specify the relative contribution of each proportion.&amp;nbsp;&lt;/SPAN&gt;&lt;/H6&gt;
&lt;H6&gt;&lt;SPAN&gt;proc shewhart data=have ;&lt;BR /&gt;&amp;nbsp; pchart pfailed*lot/subgroupn=20 dataunit=proportion;&lt;BR /&gt;run ; &lt;/SPAN&gt;&lt;/H6&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Zard_1-1715624674720.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96490iB73D6FE1654B43B8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Zard_1-1715624674720.png" alt="Zard_1-1715624674720.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H6&gt;&amp;nbsp;&lt;/H6&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2024 18:30:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/PROC-SHEWHART-pchart-weight-of-subgroups-with-varying-sizes/m-p/928186#M46219</guid>
      <dc:creator>Zard</dc:creator>
      <dc:date>2024-05-13T18:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SHEWHART pchart weight of subgroups with varying sizes</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/PROC-SHEWHART-pchart-weight-of-subgroups-with-varying-sizes/m-p/928200#M46220</link>
      <description>&lt;P&gt;Sorry, I confused your use of SUBGROUPN for LIMITN.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, I could use SUBGROUPN to tell PROC SHEWHART that there are 20 items in each subgroup, and that would calculated pbar=.2 as I would like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But of the course then the process limits are 'wrong' for subgroups with more than (or less than) 20 items.&amp;nbsp; So in my example, lot 5 should have tighter control limits because of the large sample size.&amp;nbsp; And that's what you get from SHEWHART when you tell it the sample size for each subgroup.&amp;nbsp; I don't want to change that behavior.&amp;nbsp; I just want the estimate of the process mean to be the simple mean of the group subgroup proportions, rather than a weighted mean.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2024 19:20:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/PROC-SHEWHART-pchart-weight-of-subgroups-with-varying-sizes/m-p/928200#M46220</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-05-13T19:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SHEWHART pchart weight of subgroups with varying sizes</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/PROC-SHEWHART-pchart-weight-of-subgroups-with-varying-sizes/m-p/928277#M46224</link>
      <description>&lt;P&gt;You would need to compute pbar outside of PROC SHEWHART, the way you showed. The procedure doesn't have an option for computing a simple average of proportions.&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2024 12:58:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/PROC-SHEWHART-pchart-weight-of-subgroups-with-varying-sizes/m-p/928277#M46224</guid>
      <dc:creator>Zard</dc:creator>
      <dc:date>2024-05-14T12:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SHEWHART pchart weight of subgroups with varying sizes</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/PROC-SHEWHART-pchart-weight-of-subgroups-with-varying-sizes/m-p/928413#M46249</link>
      <description>&lt;P&gt;Thanks much&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8765"&gt;@Zard&lt;/a&gt;&amp;nbsp;for helping me think this through.&amp;nbsp; I appreciate your taking the time to share examples of different approaches.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2024 00:22:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/PROC-SHEWHART-pchart-weight-of-subgroups-with-varying-sizes/m-p/928413#M46249</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-05-15T00:22:07Z</dc:date>
    </item>
  </channel>
</rss>

