<?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: proc report in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-report/m-p/56882#M15910</link>
    <description>Hi:&lt;BR /&gt;
  There is actually no need for the PROC SQL step in your code. PROC REPORT, using a COMPUTE block, can calculate a value for a row total, as shown in the example below. The program creates 2 report items CALCTOT1 and CALCTOT2, based on the use of the SALES, INVENTORY and RETURNS variables from SASHELP.SHOES. I just made up some formulas, although a simple SUM function would work as well.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
ods html file='c:\temp\calc_row_tot.html' style=sasweb;&lt;BR /&gt;
             &lt;BR /&gt;
proc report data=sashelp.shoes nowd;&lt;BR /&gt;
  title 'Method 1 - Create a computed column with a calculation';&lt;BR /&gt;
  where region in ('Asia', 'Canada', 'Pacific');&lt;BR /&gt;
  column region product sales inventory returns calctot1 calctot2;&lt;BR /&gt;
  define region / group;&lt;BR /&gt;
  define product / group;&lt;BR /&gt;
  define sales / sum 'Sales';&lt;BR /&gt;
  define inventory / sum 'Inventory';&lt;BR /&gt;
  define returns / sum 'Returns';&lt;BR /&gt;
  define calctot1 /computed 'Sales + Inventory/minus Returns' f=dollar12.;&lt;BR /&gt;
  define calctot2 / computed 'Some other formula';&lt;BR /&gt;
  compute calctot1;&lt;BR /&gt;
     calctot1 = sum(sales.sum, inventory.sum, (-1*returns.sum));&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
  compute calctot2;&lt;BR /&gt;
     calctot2 = (sum(sales.sum, inventory.sum, returns.sum) / 100) * .05;&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
  rbreak after / summarize;&lt;BR /&gt;
  break after region / summarize;&lt;BR /&gt;
  compute after region;&lt;BR /&gt;
    line ' ';&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
                &lt;BR /&gt;
ods html close;&lt;BR /&gt;
[/pre]</description>
    <pubDate>Fri, 31 Dec 2010 17:33:26 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2010-12-31T17:33:26Z</dc:date>
    <item>
      <title>proc report</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-report/m-p/56879#M15907</link>
      <description>Hi,&lt;BR /&gt;
I have a dataset like  &lt;BR /&gt;
&lt;BR /&gt;
C0	C1	  C2  	C3&lt;BR /&gt;
   1	1	1	1&lt;BR /&gt;
   2	2	2	2&lt;BR /&gt;
   3	3	3	3&lt;BR /&gt;
&lt;BR /&gt;
    &lt;BR /&gt;
  &lt;BR /&gt;
I want to create a report like  &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
C0  	C1	  C2  	C3	Total(rows)&lt;BR /&gt;
1	1	1	1	3&lt;BR /&gt;
2	2	2	2	6&lt;BR /&gt;
3	3	3	3	9&lt;BR /&gt;
Total(Cols)	5	5	5	15&lt;BR /&gt;
&lt;BR /&gt;
Total(rows) is the sum of Col1,Col2,Col3  across  rows.&lt;BR /&gt;
Total(Cols) is the sum along column where Col0 not =1.&lt;BR /&gt;
Plz help on implementing this.&lt;B&gt;&lt;/B&gt;&lt;I&gt;&lt;/I&gt;</description>
      <pubDate>Thu, 30 Dec 2010 11:31:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-report/m-p/56879#M15907</guid>
      <dc:creator>Rose</dc:creator>
      <dc:date>2010-12-30T11:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: proc report</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-report/m-p/56880#M15908</link>
      <description>Hi:&lt;BR /&gt;
  I'm confused about your data. What does C0 represent??? Are there any other identifying variables in your data, such as a name or category variable???&lt;BR /&gt;
 &lt;BR /&gt;
  Also, I do not understand the logic of why total(cols), in the lower left-hand corner is 15. If you add 3 + 6 + 9, (the numbers in each row), you get 18, not 15. There is only 1 cell where C0 = 1. But, it also seems like you are adding the 1 for C1, C2 and C3 in the row total (of 3), but excluding them from the column total to get the 15??? That does not seem consistent with your statement that you want "Total(Cols) is the sum along column where Col0 not =1."&lt;BR /&gt;
 &lt;BR /&gt;
  What other code have you tried?&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Thu, 30 Dec 2010 16:12:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-report/m-p/56880#M15908</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-12-30T16:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: proc report</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-report/m-p/56881#M15909</link>
      <description>Hi,&lt;BR /&gt;
I am not able to understand your requirements clearly.&lt;BR /&gt;
Is 'c0' a lable?why Total(cols) is having value 5 instead of 6? dont you want to consider the first row while summing up?&lt;BR /&gt;
&lt;BR /&gt;
Anyway try with the code given below.This might help you.&lt;BR /&gt;
data temp;&lt;BR /&gt;
input c0 c1 c2 c3;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 1 1 1&lt;BR /&gt;
2 2 2 2&lt;BR /&gt;
3 3 3 3&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table work.temp1&lt;BR /&gt;
as&lt;BR /&gt;
select&lt;BR /&gt;
temp.c0 as c0,&lt;BR /&gt;
temp.c1 as c1,&lt;BR /&gt;
temp.c2 as c2,&lt;BR /&gt;
temp.c3 as c3,&lt;BR /&gt;
sum(temp.c1,temp.c2,temp.c3) as totalrows&lt;BR /&gt;
from temp;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
proc report data=temp1;&lt;BR /&gt;
define c0 /group;&lt;BR /&gt;
define c1 /ANALYSIS SUM;&lt;BR /&gt;
define c2 /ANALYSIS SUM;&lt;BR /&gt;
define c3 /ANALYSIS SUM;&lt;BR /&gt;
define totalrows /ANALYSIS SUM;&lt;BR /&gt;
RBREAK AFTER /SUMMARIZE ;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
wish you a very happy new year!!</description>
      <pubDate>Fri, 31 Dec 2010 04:47:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-report/m-p/56881#M15909</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-12-31T04:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: proc report</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-report/m-p/56882#M15910</link>
      <description>Hi:&lt;BR /&gt;
  There is actually no need for the PROC SQL step in your code. PROC REPORT, using a COMPUTE block, can calculate a value for a row total, as shown in the example below. The program creates 2 report items CALCTOT1 and CALCTOT2, based on the use of the SALES, INVENTORY and RETURNS variables from SASHELP.SHOES. I just made up some formulas, although a simple SUM function would work as well.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
ods html file='c:\temp\calc_row_tot.html' style=sasweb;&lt;BR /&gt;
             &lt;BR /&gt;
proc report data=sashelp.shoes nowd;&lt;BR /&gt;
  title 'Method 1 - Create a computed column with a calculation';&lt;BR /&gt;
  where region in ('Asia', 'Canada', 'Pacific');&lt;BR /&gt;
  column region product sales inventory returns calctot1 calctot2;&lt;BR /&gt;
  define region / group;&lt;BR /&gt;
  define product / group;&lt;BR /&gt;
  define sales / sum 'Sales';&lt;BR /&gt;
  define inventory / sum 'Inventory';&lt;BR /&gt;
  define returns / sum 'Returns';&lt;BR /&gt;
  define calctot1 /computed 'Sales + Inventory/minus Returns' f=dollar12.;&lt;BR /&gt;
  define calctot2 / computed 'Some other formula';&lt;BR /&gt;
  compute calctot1;&lt;BR /&gt;
     calctot1 = sum(sales.sum, inventory.sum, (-1*returns.sum));&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
  compute calctot2;&lt;BR /&gt;
     calctot2 = (sum(sales.sum, inventory.sum, returns.sum) / 100) * .05;&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
  rbreak after / summarize;&lt;BR /&gt;
  break after region / summarize;&lt;BR /&gt;
  compute after region;&lt;BR /&gt;
    line ' ';&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
                &lt;BR /&gt;
ods html close;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Fri, 31 Dec 2010 17:33:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-report/m-p/56882#M15910</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-12-31T17:33:26Z</dc:date>
    </item>
  </channel>
</rss>

