<?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 calculate percentage with multiple rows in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/calculate-percentage-with-multiple-rows/m-p/261002#M50706</link>
    <description>&lt;P&gt;I have 2 datsets one with s_D_1, s_D_2,&lt;SPAN&gt; s_D_3, s_D_4, s_F_1, s_F_2, s_F_3, s_F_4 and the other dataset has variables n_D and n_F&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I need to merge them and calculate precentages with&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="TableStyle8"&gt;= 100*(s/n). for both D and F.&lt;/P&gt;
&lt;P class="TableStyle8"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="TableStyle8"&gt;Can any one help me in this&lt;/P&gt;</description>
    <pubDate>Mon, 04 Apr 2016 07:53:10 GMT</pubDate>
    <dc:creator>vraj1</dc:creator>
    <dc:date>2016-04-04T07:53:10Z</dc:date>
    <item>
      <title>calculate percentage with multiple rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-percentage-with-multiple-rows/m-p/261002#M50706</link>
      <description>&lt;P&gt;I have 2 datsets one with s_D_1, s_D_2,&lt;SPAN&gt; s_D_3, s_D_4, s_F_1, s_F_2, s_F_3, s_F_4 and the other dataset has variables n_D and n_F&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I need to merge them and calculate precentages with&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="TableStyle8"&gt;= 100*(s/n). for both D and F.&lt;/P&gt;
&lt;P class="TableStyle8"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="TableStyle8"&gt;Can any one help me in this&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2016 07:53:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-percentage-with-multiple-rows/m-p/261002#M50706</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2016-04-04T07:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: calculate percentage with multiple rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-percentage-with-multiple-rows/m-p/261006#M50707</link>
      <description>&lt;P&gt;Your life would be much easier if you normalised your data, i.e. have something like:&lt;/P&gt;
&lt;P&gt;S_D &amp;nbsp;RESULT&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp;abc&lt;/P&gt;
&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp;def&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;Further processing of the data would be easier, and this task would be a simple merge and one calculation step. &amp;nbsp;With your transposed dataset, you will need to use arrays, and the code thus becomes a bit more complicated - not to mention further coding will be harder. &amp;nbsp;As you have not provided test data (in the form of a datastep) this code is untested:&lt;/P&gt;
&lt;PRE&gt;data want;
  merge base other;  /* Assumes both are sorted by the id variables */
  by &amp;lt;id variables&amp;gt;;  /* update this row with the matching variables in each dataset */
  array s_d_{4};
  array s_f_{4};
  array s_d_results{4};
  array s_f_results{4};
  do i=1 to 4;
    s_d_results{i}=(s_d_{i} / n_d) * 100;
    s_f_results{i}=(s_f_{i} / n_f) * 100;
  end;
run;
 &lt;/PRE&gt;
&lt;P&gt;Again though, far easier to normalise your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2016 08:16:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-percentage-with-multiple-rows/m-p/261006#M50707</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-04T08:16:15Z</dc:date>
    </item>
  </channel>
</rss>

