<?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 proc tabulate: calculating within table from tabulate result? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-tabulate-calculating-within-table-from-tabulate-result/m-p/83386#M23945</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all, I am using the following code which generates a table showing the mean of variables oldrsd and newrsd (which are either 1 or 0 in the dataset), by year.&lt;/P&gt;&lt;P&gt; -----------------------&lt;/P&gt;&lt;P&gt;proc tabulate data=geo.newperson;&lt;/P&gt;&lt;P&gt;class dx_year;&lt;/P&gt;&lt;P&gt;var oldrsd newrsd;&lt;/P&gt;&lt;P&gt;table dx_year, (oldrsd newrsd)*(mean='Pct'*F=8.2);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt; -----------------------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I'd like to do is to have a third column which would show the difference between the means as calculated by proc tabulate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g the current table shows&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oldrsd&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newrsd&lt;/P&gt;&lt;P&gt;2000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .50&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .70&lt;/P&gt;&lt;P&gt;2001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .40&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .90&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but would like it to show&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oldrsd&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newrsd&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; diff&lt;/P&gt;&lt;P&gt;2000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .50&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .70&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .20&lt;/P&gt;&lt;P&gt;2001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .40&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .90&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .50&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;---------------------------------&lt;/P&gt;&lt;P&gt;Is this possible to do, within proc tabulate? Or what would be an efficient way to do this?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 Mar 2013 15:58:37 GMT</pubDate>
    <dc:creator>ucdcrush</dc:creator>
    <dc:date>2013-03-20T15:58:37Z</dc:date>
    <item>
      <title>proc tabulate: calculating within table from tabulate result?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-tabulate-calculating-within-table-from-tabulate-result/m-p/83386#M23945</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all, I am using the following code which generates a table showing the mean of variables oldrsd and newrsd (which are either 1 or 0 in the dataset), by year.&lt;/P&gt;&lt;P&gt; -----------------------&lt;/P&gt;&lt;P&gt;proc tabulate data=geo.newperson;&lt;/P&gt;&lt;P&gt;class dx_year;&lt;/P&gt;&lt;P&gt;var oldrsd newrsd;&lt;/P&gt;&lt;P&gt;table dx_year, (oldrsd newrsd)*(mean='Pct'*F=8.2);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt; -----------------------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I'd like to do is to have a third column which would show the difference between the means as calculated by proc tabulate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g the current table shows&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oldrsd&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newrsd&lt;/P&gt;&lt;P&gt;2000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .50&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .70&lt;/P&gt;&lt;P&gt;2001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .40&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .90&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but would like it to show&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oldrsd&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newrsd&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; diff&lt;/P&gt;&lt;P&gt;2000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .50&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .70&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .20&lt;/P&gt;&lt;P&gt;2001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .40&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .90&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .50&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;---------------------------------&lt;/P&gt;&lt;P&gt;Is this possible to do, within proc tabulate? Or what would be an efficient way to do this?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 15:58:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-tabulate-calculating-within-table-from-tabulate-result/m-p/83386#M23945</guid>
      <dc:creator>ucdcrush</dc:creator>
      <dc:date>2013-03-20T15:58:37Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate: calculating within table from tabulate result?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-tabulate-calculating-within-table-from-tabulate-result/m-p/83387#M23946</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can take the output table from proc tabulate and add that column in and then report it. &lt;/P&gt;&lt;P&gt;I don't know if there's a mathematical shortcut for the difference.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 16:21:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-tabulate-calculating-within-table-from-tabulate-result/m-p/83387#M23946</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-03-20T16:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate: calculating within table from tabulate result?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-tabulate-calculating-within-table-from-tabulate-result/m-p/83388#M23947</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If it's easier, you could always compute DIFF on your input data set:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;diff = newrsd - oldrsd;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then let PROC TABULATE compute its mean as well as the mean of the other variables.&amp;nbsp; The mean value would be the same as long as there are no missing values for the incoming variables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 17:50:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-tabulate-calculating-within-table-from-tabulate-result/m-p/83388#M23947</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-03-20T17:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate: calculating within table from tabulate result?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-tabulate-calculating-within-table-from-tabulate-result/m-p/83389#M23948</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Reeza and Astounding. Calculating it before seems the quickest way since one can simply add diff in as a variable to have the mean computed along with newrsd and oldrsd in the proc tabulate, without having to do any wrangling on an output table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 18:03:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-tabulate-calculating-within-table-from-tabulate-result/m-p/83389#M23948</guid>
      <dc:creator>ucdcrush</dc:creator>
      <dc:date>2013-03-20T18:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate: calculating within table from tabulate result?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-tabulate-calculating-within-table-from-tabulate-result/m-p/83390#M23949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp; OR, as much as I love TABULATE, you could do it all in one pass through the data with PROC REPORT.&lt;/P&gt;&lt;P&gt;cynthia&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;ods html file='c:\temp\calcdiff.html';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;proc report data=sashelp.shoes nowd;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; column region inventory sales diff;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; define region/ group;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; define sales / mean;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; define inventory / mean;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; define diff / computed f=dollar12.;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; compute diff;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; diff =&amp;nbsp; inventory.mean - sales.mean;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; endcomp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; rbreak after / summarize;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;ods html close;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 19:23:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-tabulate-calculating-within-table-from-tabulate-result/m-p/83390#M23949</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2013-03-20T19:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate: calculating within table from tabulate result?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-tabulate-calculating-within-table-from-tabulate-result/m-p/83391#M23950</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Cynthia, that is great. I didn't know proc report was so straightforward, I will probably use it more often than tabulate now. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 20:18:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-tabulate-calculating-within-table-from-tabulate-result/m-p/83391#M23950</guid>
      <dc:creator>ucdcrush</dc:creator>
      <dc:date>2013-03-20T20:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate: calculating within table from tabulate result?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-tabulate-calculating-within-table-from-tabulate-result/m-p/83392#M23951</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I call TABULATE and REPORT the "dream team" of SAS reporting. TABULATE is the slicer and dicer and power 3 dimensional --( nestings in every dimension) report procedure and REPORT is the "Swiss Army Knife" with the fold out tools report procedure -- PROC REPORT does detail reports, like PRINT; it can calculate summary statistics like MEANS and TABULATE; it can do crosstabs; it can calculate new columns from report items in the COLUMN statement (such as DIFF); it can have customized break lines. They each have a purpose, but when you talk about making 2 passes through the data to get TABULATE to have a column that needs to be computed, that's the time to look at REPORT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cynthia&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Mar 2013 15:51:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-tabulate-calculating-within-table-from-tabulate-result/m-p/83392#M23951</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2013-03-21T15:51:26Z</dc:date>
    </item>
  </channel>
</rss>

