<?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 Calculating a relative value using proc report in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Calculating-a-relative-value-using-proc-report/m-p/22822#M3991</link>
    <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
I have a situation whereby i need to calculate a value for each row, relative to the first row.&lt;BR /&gt;
&lt;BR /&gt;
ie.  if i have the following table   &lt;BR /&gt;
&lt;BR /&gt;
a  b  c&lt;BR /&gt;
                                  d  e  f&lt;BR /&gt;
                                              g  h  i&lt;BR /&gt;
&lt;BR /&gt;
then i wish to calculate   &lt;BR /&gt;
&lt;BR /&gt;
a  b  c/c&lt;BR /&gt;
                                    d  e   f/c&lt;BR /&gt;
                                    g  h   i/c&lt;BR /&gt;
&lt;BR /&gt;
I have been able to do this using data steps and tabulates however because i repeat the calculation many times it is very time consuming and computationally demanding.&lt;BR /&gt;
&lt;BR /&gt;
I have also been able to calculate the value for consecutive rows, but cannot keep dividing by the value c.&lt;BR /&gt;
&lt;BR /&gt;
Any help would be greatly appreciated.&lt;BR /&gt;
Chis</description>
    <pubDate>Wed, 04 Jun 2008 08:20:29 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-06-04T08:20:29Z</dc:date>
    <item>
      <title>Calculating a relative value using proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Calculating-a-relative-value-using-proc-report/m-p/22822#M3991</link>
      <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
I have a situation whereby i need to calculate a value for each row, relative to the first row.&lt;BR /&gt;
&lt;BR /&gt;
ie.  if i have the following table   &lt;BR /&gt;
&lt;BR /&gt;
a  b  c&lt;BR /&gt;
                                  d  e  f&lt;BR /&gt;
                                              g  h  i&lt;BR /&gt;
&lt;BR /&gt;
then i wish to calculate   &lt;BR /&gt;
&lt;BR /&gt;
a  b  c/c&lt;BR /&gt;
                                    d  e   f/c&lt;BR /&gt;
                                    g  h   i/c&lt;BR /&gt;
&lt;BR /&gt;
I have been able to do this using data steps and tabulates however because i repeat the calculation many times it is very time consuming and computationally demanding.&lt;BR /&gt;
&lt;BR /&gt;
I have also been able to calculate the value for consecutive rows, but cannot keep dividing by the value c.&lt;BR /&gt;
&lt;BR /&gt;
Any help would be greatly appreciated.&lt;BR /&gt;
Chis</description>
      <pubDate>Wed, 04 Jun 2008 08:20:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Calculating-a-relative-value-using-proc-report/m-p/22822#M3991</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-06-04T08:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating a relative value using proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Calculating-a-relative-value-using-proc-report/m-p/22823#M3992</link>
      <description>Does this work for you? It assumes that z will never be missing.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data;&lt;BR /&gt;
input x y z;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 2 3&lt;BR /&gt;
4 5 6&lt;BR /&gt;
7 8 9&lt;BR /&gt;
;;;;&lt;BR /&gt;
proc report nowd;&lt;BR /&gt;
  col x y z z2;&lt;BR /&gt;
  define x--y / display;&lt;BR /&gt;
  define z / display noprint;&lt;BR /&gt;
  define z2 / computed;&lt;BR /&gt;
  compute z2;&lt;BR /&gt;
    if keep = . then keep = z;&lt;BR /&gt;
    z2 = z / keep;&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
run;[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Produces&lt;BR /&gt;
[pre]&lt;BR /&gt;
x          y         z2&lt;BR /&gt;
1          2          1&lt;BR /&gt;
4          5          2&lt;BR /&gt;
7          8          3&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 04 Jun 2008 12:35:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Calculating-a-relative-value-using-proc-report/m-p/22823#M3992</guid>
      <dc:creator>Tim_SAS</dc:creator>
      <dc:date>2008-06-04T12:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating a relative value using proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Calculating-a-relative-value-using-proc-report/m-p/22824#M3993</link>
      <description>That's a fantastic solution, excellent bit of code.&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Chris</description>
      <pubDate>Wed, 04 Jun 2008 15:57:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Calculating-a-relative-value-using-proc-report/m-p/22824#M3993</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-06-04T15:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating a relative value using proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Calculating-a-relative-value-using-proc-report/m-p/22825#M3994</link>
      <description>Hi again,&lt;BR /&gt;
&lt;BR /&gt;
I've used the bit of code supplied ealier and it has worked well, however i have been unable to adapt it to deal with the following problem:&lt;BR /&gt;
&lt;BR /&gt;
If i have a report that is grouped by month, i need the relative figure to be figured out independantly for each month.&lt;BR /&gt;
&lt;BR /&gt;
ie. if i have&lt;BR /&gt;
&lt;BR /&gt;
month   x  y  z&lt;BR /&gt;
&lt;BR /&gt;
Jan       1  2  3&lt;BR /&gt;
Jan       4  5  6&lt;BR /&gt;
Jan       7  8  9&lt;BR /&gt;
Feb      a  d  c&lt;BR /&gt;
Feb      d  e   f&lt;BR /&gt;
Feb      h   i   j&lt;BR /&gt;
&lt;BR /&gt;
I need to calculate&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Jan      1  2  3  3/3&lt;BR /&gt;
Jan      4  5  6  6/3&lt;BR /&gt;
Jan      7  8  9  9/3&lt;BR /&gt;
Feb     a  b  c   c/c&lt;BR /&gt;
Feb     d  e   f   f/c&lt;BR /&gt;
Feb     g  h   i   i/c&lt;BR /&gt;
&lt;BR /&gt;
Any help would be greatly appreciated.&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Chris</description>
      <pubDate>Fri, 06 Jun 2008 12:47:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Calculating-a-relative-value-using-proc-report/m-p/22825#M3994</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-06-06T12:47:41Z</dc:date>
    </item>
  </channel>
</rss>

