<?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: Calculate percentage in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage/m-p/632283#M187442</link>
    <description>&lt;P&gt;Its really hard to generalize from your example&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If tot_pop is the sum of the other CNT values, then you don't need it. (Is it always going to be the sum of the other CNT values?)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But assuming it is the sum of the other CNT values, get rid of the tot_pop line, delete it from your data set, and then run PROC FREQ to get your percentages.&lt;/P&gt;</description>
    <pubDate>Sun, 15 Mar 2020 22:11:04 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-03-15T22:11:04Z</dc:date>
    <item>
      <title>Calculate percentage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage/m-p/632280#M187440</link>
      <description>&lt;P&gt;data have;&lt;BR /&gt;length Status $25.;&lt;BR /&gt;input Status cnt;&lt;BR /&gt;return;&lt;BR /&gt;datalines;&lt;BR /&gt;Tot_pop 10&lt;BR /&gt;Curr 5&lt;BR /&gt;_30_day 1&lt;BR /&gt;Paid 4&lt;BR /&gt;;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 96pt;" border="0" width="128" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" style="height: 15.0pt; width: 48pt;"&gt;Status&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;cnt&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" style="height: 15.0pt;"&gt;Tot_pop&lt;/TD&gt;
&lt;TD align="right"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" style="height: 15.0pt;"&gt;Curr&lt;/TD&gt;
&lt;TD align="right"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" style="height: 15.0pt;"&gt;_30_day&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" style="height: 15.0pt;"&gt;Paid&lt;/TD&gt;
&lt;TD align="right"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to calculate the percentage change using Tot_Pop as the base line.&amp;nbsp; Idea is to divide Curr/Tot_pop and show results on Curr row, then _30_day/tot_pop and show on _30_day row?&lt;/P&gt;</description>
      <pubDate>Sun, 15 Mar 2020 22:06:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage/m-p/632280#M187440</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2020-03-15T22:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage/m-p/632283#M187442</link>
      <description>&lt;P&gt;Its really hard to generalize from your example&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If tot_pop is the sum of the other CNT values, then you don't need it. (Is it always going to be the sum of the other CNT values?)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But assuming it is the sum of the other CNT values, get rid of the tot_pop line, delete it from your data set, and then run PROC FREQ to get your percentages.&lt;/P&gt;</description>
      <pubDate>Sun, 15 Mar 2020 22:11:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage/m-p/632283#M187442</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-15T22:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage/m-p/632527#M187541</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/5629"&gt;@Q1983&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;data have;&lt;BR /&gt;length Status $25.;&lt;BR /&gt;input Status cnt;&lt;BR /&gt;return;&lt;BR /&gt;datalines;&lt;BR /&gt;Tot_pop 10&lt;BR /&gt;Curr 5&lt;BR /&gt;_30_day 1&lt;BR /&gt;Paid 4&lt;BR /&gt;;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="128" style="width: 96pt; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD width="64" height="20" style="width: 48pt; height: 15pt;"&gt;Status&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;cnt&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" style="height: 15pt;"&gt;Tot_pop&lt;/TD&gt;
&lt;TD align="right"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" style="height: 15pt;"&gt;Curr&lt;/TD&gt;
&lt;TD align="right"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" style="height: 15pt;"&gt;_30_day&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD height="20" style="height: 15pt;"&gt;Paid&lt;/TD&gt;
&lt;TD align="right"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to calculate the percentage change using Tot_Pop as the base line.&amp;nbsp; Idea is to divide Curr/Tot_pop and show results on Curr row, then _30_day/tot_pop and show on _30_day row?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I would call this a good example of why not to include summary data in data if Tot_pop is supposed to be the sume of Curr, _30_day and Paid. Especially if you calculated it previously.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One take on what I think is similar to what you want:&lt;/P&gt;
&lt;PRE&gt;data have;
length Status $25.;
input Status cnt;
return;
datalines;
Tot_pop 10
Curr 5
_30_day 1
Paid 4
;
run;

proc tabulate data=have;
   where status ne 'Tot_pop';
   var cnt;
   class status;
   table status all='Tot_pop',
         cnt *(sum pctsum)
   ;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Mar 2020 19:42:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage/m-p/632527#M187541</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-03-16T19:42:53Z</dc:date>
    </item>
  </channel>
</rss>

