<?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 between the variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage-between-the-variables/m-p/511946#M137810</link>
    <description>I agree with you that it seems to lazy. I had this feeling from the first post and now you share the same feeling.</description>
    <pubDate>Sat, 10 Nov 2018 18:17:08 GMT</pubDate>
    <dc:creator>trungdungtran</dc:creator>
    <dc:date>2018-11-10T18:17:08Z</dc:date>
    <item>
      <title>Calculate percentage between the variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage-between-the-variables/m-p/511638#M137709</link>
      <description>&lt;P&gt;I've the data as follows and I need to calculate the percentage of difference between the variables 'amount1' and 'amount2' by ignoring the negative sign.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Input data:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="178"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="71"&gt;AMOUNT1&lt;/TD&gt;
&lt;TD width="107"&gt;AMOUNT2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;100&lt;/TD&gt;
&lt;TD&gt;110&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;200&lt;/TD&gt;
&lt;TD&gt;220&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1000&lt;/TD&gt;
&lt;TD&gt;100&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;100&lt;/TD&gt;
&lt;TD&gt;20&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1000&lt;/TD&gt;
&lt;TD&gt;900&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Desired Output:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="325"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="71"&gt;AMOUNT1&lt;/TD&gt;
&lt;TD width="107"&gt;AMOUNT2&lt;/TD&gt;
&lt;TD width="147"&gt;Diff in percent&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;100&lt;/TD&gt;
&lt;TD&gt;110&lt;/TD&gt;
&lt;TD&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;200&lt;/TD&gt;
&lt;TD&gt;220&lt;/TD&gt;
&lt;TD&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1000&lt;/TD&gt;
&lt;TD&gt;100&lt;/TD&gt;
&lt;TD&gt;90&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;100&lt;/TD&gt;
&lt;TD&gt;20&lt;/TD&gt;
&lt;TD&gt;80&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1000&lt;/TD&gt;
&lt;TD&gt;900&lt;/TD&gt;
&lt;TD&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Datastep to create the data:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data A;
Input AMOUNT1 AMOUNT2 ;
cards;
100 110
200 220
1000 100
100 20
1000 900
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Nov 2018 11:42:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage-between-the-variables/m-p/511638#M137709</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-11-09T11:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage between the variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage-between-the-variables/m-p/511639#M137710</link>
      <description>Use range( amount1, amount2) / amount1</description>
      <pubDate>Fri, 09 Nov 2018 11:49:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage-between-the-variables/m-p/511639#M137710</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2018-11-09T11:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage between the variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage-between-the-variables/m-p/511640#M137711</link>
      <description>&lt;P&gt;You can use&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data B;
	set A;
	diff=round(abs(AMOUNT2-AMOUNT1)/AMOUNT1*100);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;where abs is absolute value, i.e., ignoring negative. If you do not need round, then you can remove it.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Nov 2018 11:53:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage-between-the-variables/m-p/511640#M137711</guid>
      <dc:creator>trungdungtran</dc:creator>
      <dc:date>2018-11-09T11:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage between the variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage-between-the-variables/m-p/511641#M137712</link>
      <description>&lt;P&gt;Or try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set a;
if amount1&amp;gt;0 then diffpct=round(abs(amount2/amount1-1)*100,1e-9);
else diffpct=.;
label diffpct='Diff in percent';
run;

proc print data=want label noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Nov 2018 11:53:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage-between-the-variables/m-p/511641#M137712</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-11-09T11:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage between the variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage-between-the-variables/m-p/511649#M137714</link>
      <description>&lt;P&gt;What format should I use to display the percentage with percent sign (%) as shown below?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="147"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="147"&gt;Diff in percent&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;10%&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;10%&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;90%&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;80%&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;10%&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Fri, 09 Nov 2018 12:22:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage-between-the-variables/m-p/511649#M137714</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-11-09T12:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage between the variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage-between-the-variables/m-p/511650#M137715</link>
      <description>&lt;P&gt;If you want the differences shown with a percent sign, the easiest is to calculate the absolute relative difference, and use the PERCENT. format to display as a percent:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set a;
  rel_diff=abs((amount1-amount2)/amount1);
  format rel_diff percent5.0;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Nov 2018 12:30:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage-between-the-variables/m-p/511650#M137715</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-11-09T12:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage between the variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage-between-the-variables/m-p/511654#M137718</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;What format should I use to display the percentage with percent sign (%) as shown below?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="147"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="147"&gt;Diff in percent&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;10%&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;10%&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;90%&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;80%&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;10%&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are you really too lazy to google "sas percent"?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Nov 2018 12:49:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage-between-the-variables/m-p/511654#M137718</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-09T12:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage between the variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage-between-the-variables/m-p/511659#M137720</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="147"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="147"&gt;Diff in percent&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;10%&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Also, I don't think it's the best style to write &lt;EM&gt;both&lt;/EM&gt; percent signs&amp;nbsp;after the numbers&amp;nbsp;&lt;EM&gt;and&lt;/EM&gt; "in percent" in the header (same with other units of measurement).&lt;/P&gt;</description>
      <pubDate>Fri, 09 Nov 2018 13:10:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage-between-the-variables/m-p/511659#M137720</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-11-09T13:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage between the variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage-between-the-variables/m-p/511946#M137810</link>
      <description>I agree with you that it seems to lazy. I had this feeling from the first post and now you share the same feeling.</description>
      <pubDate>Sat, 10 Nov 2018 18:17:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-percentage-between-the-variables/m-p/511946#M137810</guid>
      <dc:creator>trungdungtran</dc:creator>
      <dc:date>2018-11-10T18:17:08Z</dc:date>
    </item>
  </channel>
</rss>

