<?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: Percentage within each category in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Percentage-within-each-category/m-p/857410#M338801</link>
    <description>Thank you for your help.</description>
    <pubDate>Mon, 06 Feb 2023 17:00:39 GMT</pubDate>
    <dc:creator>sascode</dc:creator>
    <dc:date>2023-02-06T17:00:39Z</dc:date>
    <item>
      <title>Percentage within each category</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Percentage-within-each-category/m-p/857396#M338797</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have a dataset as below:&lt;/P&gt;
&lt;PRE&gt;data have;
input exam $ passed;
datalines;
A 0
A 1
B 1
C 0
D 1
E 0
E 1
;
run;&lt;/PRE&gt;
&lt;P&gt;Using tabulate procedure i am able to generate total counts correctly, but in ColPctn, i would like to have percentages within in each exam. for instance: first row of output should&lt;/P&gt;
&lt;P&gt;be 50% (1 passed / 2 all) = 0.5 , and not&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the code i am using below&amp;nbsp; :&lt;BR /&gt;title "CrossTab";&lt;/P&gt;
&lt;PRE&gt;proc tabulate data = have;
class exam;
var passed;
table exam ,
passed*( N SUM='Passed'*f= 10. colpctn);
keylabel all = "Total";
run;&lt;/PRE&gt;
&lt;P&gt;and the output which is not coming as i need:&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Tabulate: Table 1" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c m header" rowspan="2" scope="col"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TH class="c header" colspan="3" scope="colgroup"&gt;passed&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="c header" scope="col"&gt;N&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;Passed&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;ColPctN&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;exam&lt;/TH&gt;
&lt;TD rowspan="2" class="r b data"&gt;2&lt;/TD&gt;
&lt;TD rowspan="2" class="r b data"&gt;1&lt;/TD&gt;
&lt;TD rowspan="2" class="r b data"&gt;28.57&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;A&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;B&lt;/TH&gt;
&lt;TD class="r b data"&gt;1&lt;/TD&gt;
&lt;TD class="r b data"&gt;1&lt;/TD&gt;
&lt;TD class="r b data"&gt;14.29&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;C&lt;/TH&gt;
&lt;TD class="r b data"&gt;1&lt;/TD&gt;
&lt;TD class="r b data"&gt;0&lt;/TD&gt;
&lt;TD class="r b data"&gt;14.29&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;D&lt;/TH&gt;
&lt;TD class="r b data"&gt;1&lt;/TD&gt;
&lt;TD class="r b data"&gt;1&lt;/TD&gt;
&lt;TD class="r b data"&gt;14.29&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;E&lt;/TH&gt;
&lt;TD class="r b data"&gt;2&lt;/TD&gt;
&lt;TD class="r b data"&gt;1&lt;/TD&gt;
&lt;TD class="r b data"&gt;28.57&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;I would appreciate any suggestion .&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2023 16:13:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Percentage-within-each-category/m-p/857396#M338797</guid>
      <dc:creator>sascode</dc:creator>
      <dc:date>2023-02-06T16:13:07Z</dc:date>
    </item>
    <item>
      <title>Re: Percentage within each category</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Percentage-within-each-category/m-p/857406#M338799</link>
      <description>&lt;P&gt;Percentages can be tricky but in this case there is an easy solution:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data = have;
class exam;
var passed;
table exam ,
passed*( N SUM='Passed'*f= 10. mean='% Passed'*f=percent8.2);
keylabel all = "Total";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When dealing with a 0/1 variable, the mean is the same as the percentage of "1" values.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2023 16:51:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Percentage-within-each-category/m-p/857406#M338799</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2023-02-06T16:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: Percentage within each category</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Percentage-within-each-category/m-p/857410#M338801</link>
      <description>Thank you for your help.</description>
      <pubDate>Mon, 06 Feb 2023 17:00:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Percentage-within-each-category/m-p/857410#M338801</guid>
      <dc:creator>sascode</dc:creator>
      <dc:date>2023-02-06T17:00:39Z</dc:date>
    </item>
  </channel>
</rss>

