<?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: Proc Tabulate Custom Percent Calculation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-Custom-Percent-Calculation/m-p/435670#M108249</link>
    <description>&lt;P&gt;Given&amp;nbsp; your data example you may want to presummarize counts and calculate the rate. My reasons for this are 1) your variable grad_status is apparently character which means it can only be used as a class variable, 2) unless you use the option missing for the class variable grad_status you will have a lot of records excluded (tabulate by default excludes any record with any class variable missing) and 3) the pctn&amp;lt;&amp;gt; calculation will create columns for the "missing" grad_status.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your explanation is also a bit incomplete. You claim "The first table shows a total of 7 Female Non Resident aliens and of them 5 transferred which makes it 71% for that cell (5/7=71%).". I do not see any indication of 7 Female Non-resident aliens.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sometimes it makes a lot of sense to create indicator variables such a 1/0 for "Transfer without Graduation". Create a variable if the status is know with 1 for true(Transfer without Graduation) and 0 for not. Then you can use tabulate statistics to do 3 things: n =&amp;gt; how many valid records, sum =&amp;gt; number of true(or yes or however you think of it) and mean will give percentage as a decimal.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might get a more targeted response providing a small data set in the form a data step to test data with. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
    <pubDate>Fri, 09 Feb 2018 15:36:00 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-02-09T15:36:00Z</dc:date>
    <item>
      <title>Proc Tabulate Custom Percent Calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-Custom-Percent-Calculation/m-p/435666#M108247</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to figure out how to do custom percentage using Proc Tabulate. I have given the table below as example for only one race. I need to do this for all races. The actual data looks like this;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Gender&lt;/TD&gt;&lt;TD&gt;Race&lt;/TD&gt;&lt;TD&gt;grad_status&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Female&lt;/TD&gt;&lt;TD&gt;NRALien&lt;/TD&gt;&lt;TD&gt;Transfer without Graduation&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;Female&lt;/TD&gt;&lt;TD&gt;NRALien&lt;/TD&gt;&lt;TD&gt;Transfer without Graduation&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;Female&lt;/TD&gt;&lt;TD&gt;NRALien&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;Female&lt;/TD&gt;&lt;TD&gt;NRALien&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;Female&lt;/TD&gt;&lt;TD&gt;NRALien&lt;/TD&gt;&lt;TD&gt;Transfer without Graduation&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;Female&lt;/TD&gt;&lt;TD&gt;NRALien&lt;/TD&gt;&lt;TD&gt;Transfer without Graduation&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;Female&lt;/TD&gt;&lt;TD&gt;NRALien&lt;/TD&gt;&lt;TD&gt;Transfer without Graduation&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;Male&lt;/TD&gt;&lt;TD&gt;NRALien&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;Male&lt;/TD&gt;&lt;TD&gt;NRALien&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;Male&lt;/TD&gt;&lt;TD&gt;NRALien&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;TD&gt;Male&lt;/TD&gt;&lt;TD&gt;NRALien&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;Male&lt;/TD&gt;&lt;TD&gt;NRALien&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;I did a Proc Tabulate on numbers and it looks like below. The table shows for all races.&amp;nbsp;&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="45.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18419i702F44AA0B78073E/image-size/large?v=v2&amp;amp;px=999" role="button" title="45.JPG" alt="45.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I will use Non_resident Alien as example. The Proc Tabulate table above shows 5 female non-resident aliens who transferred. I want to know "Of the Total Female Non Resident Aliens, what percentage transferred"?. The first table shows a total of 7 Female Non Resident aliens and of them 5 transferred which makes it 71% for that cell (5/7=71%).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another example -there are 14 male Hispanic who graduated. I want to know - "Of all Male Hispanic Students", 14 graduated. According to my data (have not shown here), there are total of 66 Male Hispanic which makes that cell 14/66=21%&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically I have to do this same percent calculation for all cells.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help will be greatly appreciated.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 15:18:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-Custom-Percent-Calculation/m-p/435666#M108247</guid>
      <dc:creator>anandas</dc:creator>
      <dc:date>2018-02-09T15:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Tabulate Custom Percent Calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-Custom-Percent-Calculation/m-p/435670#M108249</link>
      <description>&lt;P&gt;Given&amp;nbsp; your data example you may want to presummarize counts and calculate the rate. My reasons for this are 1) your variable grad_status is apparently character which means it can only be used as a class variable, 2) unless you use the option missing for the class variable grad_status you will have a lot of records excluded (tabulate by default excludes any record with any class variable missing) and 3) the pctn&amp;lt;&amp;gt; calculation will create columns for the "missing" grad_status.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your explanation is also a bit incomplete. You claim "The first table shows a total of 7 Female Non Resident aliens and of them 5 transferred which makes it 71% for that cell (5/7=71%).". I do not see any indication of 7 Female Non-resident aliens.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sometimes it makes a lot of sense to create indicator variables such a 1/0 for "Transfer without Graduation". Create a variable if the status is know with 1 for true(Transfer without Graduation) and 0 for not. Then you can use tabulate statistics to do 3 things: n =&amp;gt; how many valid records, sum =&amp;gt; number of true(or yes or however you think of it) and mean will give percentage as a decimal.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might get a more targeted response providing a small data set in the form a data step to test data with. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 15:36:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-Custom-Percent-Calculation/m-p/435670#M108249</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-02-09T15:36:00Z</dc:date>
    </item>
  </channel>
</rss>

