<?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 Lower and upper bounds for proportions in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Lower-and-upper-bounds-for-proportions/m-p/751624#M36560</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;The variable lab_pred is a binary variable indicating whether or not the person works (1=work).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edu, sex, and agegr are categorical variables for the education (4 categories: 0,1,2,3), sex (two categories: 0,01) and age groups (from 15 to 70 by 5 years). For each combination of sex*edu*agegr, I want to calculate the proportion that works and the lower and upper bounds.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To produce this outcomes, I use the following code, but it produces a different table for each sub-category of sex*edu*agegr.&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-sas"&gt;proc sort data=work.predict2; by sex edu agegr; run;
proc freq data=work.predict2;
table lab_pred /nocol nofreq nopercent binomial (CL=Wald(correct));
by sex edu agegr;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;How can I generate an output that will look like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="542"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="114"&gt;Sex&lt;/TD&gt;
&lt;TD width="84"&gt;Agegr&lt;/TD&gt;
&lt;TD width="84"&gt;Edu&lt;/TD&gt;
&lt;TD width="92"&gt;% lab_pred=1&lt;/TD&gt;
&lt;TD width="84"&gt;Lower CI&lt;/TD&gt;
&l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lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 02 Jul 2021 06:37:08 GMT</pubDate>
    <dc:creator>Demographer</dc:creator>
    <dc:date>2021-07-02T06:37:08Z</dc:date>
    <item>
      <title>Lower and upper bounds for proportions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Lower-and-upper-bounds-for-proportions/m-p/751624#M36560</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;The variable lab_pred is a binary variable indicating whether or not the person works (1=work).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edu, sex, and agegr are categorical variables for the education (4 categories: 0,1,2,3), sex (two categories: 0,01) and age groups (from 15 to 70 by 5 years). For each combination of sex*edu*agegr, I want to calculate the proportion that works and the lower and upper bounds.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To produce this outcomes, I use the following code, but it produces a different table for each sub-category of sex*edu*agegr.&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-sas"&gt;proc sort data=work.predict2; by sex edu agegr; run;
proc freq data=work.predict2;
table lab_pred /nocol nofreq nopercent binomial (CL=Wald(correct));
by sex edu agegr;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;How can I generate an output that will look like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;T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&gt;
&lt;TD&gt;…&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;70&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 06:37:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Lower-and-upper-bounds-for-proportions/m-p/751624#M36560</guid>
      <dc:creator>Demographer</dc:creator>
      <dc:date>2021-07-02T06:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: Lower and upper bounds for proportions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Lower-and-upper-bounds-for-proportions/m-p/751636#M36561</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/33143"&gt;@Demographer&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/procstat/procstat_freq_syntax07.htm" target="_blank" rel="noopener"&gt;OUTPUT statement&lt;/A&gt; to obtain the desired output dataset, possibly with a KEEP= dataset option to restrict it to the statistics of interest (e.g.,&amp;nbsp;&lt;FONT face="courier new,courier"&gt;... out=want&lt;STRONG&gt;(keep=sex edu agegr _bin_ l_bin u_bin)&lt;/STRONG&gt;&lt;/FONT&gt;).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=work.predict2 noprint;
table lab_pred /nocol nofreq nopercent binomial (level='1' CL=Wald(correct));
by sex edu agegr;
output out=want binomial;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The NOPRINT option of the PROC FREQ statement is optional, just to suppress the printed output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: The LEVEL='1' option is important if the other level of LAB_PRED is 0 because in this case 0 (the first level) would be the default in the calculation of statistics.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 07:38:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Lower-and-upper-bounds-for-proportions/m-p/751636#M36561</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-07-02T07:38:41Z</dc:date>
    </item>
    <item>
      <title>Re: Lower and upper bounds for proportions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Lower-and-upper-bounds-for-proportions/m-p/751750#M36569</link>
      <description>&lt;P&gt;In order to use all of the data in the computation of each of the proportions, a modeling approach is needed. PROC FREQ with a BY statement will only use the data in the one BY group when computing the proportion. The following fits a logistic model to predict the probability of work in each combination. The possible downside to this approach is convergence problems if the data are sparse, particularly if there is a zero count in any of the cells of the four-way table using all of the variables. If not, then the LSMEANS statement with the ILINK option gives the proportions and the CL option gives the confidence limits.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc logistic;
class edu sex agegr / param=glm;
model lab_pred(event="1")=edu|sex|agegr;
lsmeans edu*sex*agegr / ilink cl;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Jul 2021 14:41:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Lower-and-upper-bounds-for-proportions/m-p/751750#M36569</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2021-07-02T14:41:30Z</dc:date>
    </item>
  </channel>
</rss>

