<?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 tabulate question in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-tabulate-question/m-p/69606#M20008</link>
    <description>Hi:&lt;BR /&gt;
  As soon as you put&lt;BR /&gt;
&lt;B&gt;* (Currency (all='Sum'))* &lt;/B&gt;&lt;BR /&gt;
into the ROW dimension crossed with MONTH and PRODUCT, you are going to get that summary (ALL) for Currency -- &lt;BR /&gt;
whether you have 1 currency or 10 or 100 currency values in the table. The way TABULATE works is that the table rows for CURRENCY are &lt;BR /&gt;
placed in the row dimension, then you have a space or blank operator and then the ALL -- that means after the CURRENCY rows have been written, &lt;BR /&gt;
the ALL row(s) will be written -- the ALL has no visibility of how many values there were for CURRENCY.&lt;BR /&gt;
 &lt;BR /&gt;
  Possibly reworking your ROW dimension might help you figure out a slightly different approach. Here are two different examples in the code below --&lt;BR /&gt;
 note that there are different TABLE statements so you'll have to scroll down to see the results. The BOX= option was used to provide a name &lt;BR /&gt;
for each table.&lt;BR /&gt;
 &lt;BR /&gt;
And, here are some papers about PROC TABULATE that may help you understand the ALL usage and the space/blank and  * usage a bit better.&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi27/p060-27.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi27/p060-27.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi30/243-30.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi30/243-30.pdf&lt;/A&gt;&lt;BR /&gt;
 &lt;A href="http://www2.sas.com/proceedings/sugi30/258-30.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi30/258-30.pdf&lt;/A&gt;&lt;BR /&gt;
              &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
data mydata;&lt;BR /&gt;
  infile datalines dlm=',' dsd;&lt;BR /&gt;
  input month currency $ product amount;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1, EUR, 1, 100&lt;BR /&gt;
1, USD, 2, 200&lt;BR /&gt;
1, USD, 1, 100&lt;BR /&gt;
1, EUR, 3, 300&lt;BR /&gt;
1, EUR, 4, 400&lt;BR /&gt;
2, EUR, 1, 300&lt;BR /&gt;
2, EUR, 4, 150&lt;BR /&gt;
2, EUR, 3, 150&lt;BR /&gt;
2, EUR, 2, 400&lt;BR /&gt;
2, EUR, 1, 500&lt;BR /&gt;
2, EUR, 2, 100&lt;BR /&gt;
2, EUR, 1, 300&lt;BR /&gt;
3, USD, 4, 100 &lt;BR /&gt;
3, USD, 3, 200 &lt;BR /&gt;
3, EUR, 2, 300 &lt;BR /&gt;
3, EUR, 1, 400  &lt;BR /&gt;
3, USD, 2, 100 &lt;BR /&gt;
3, USD, 3, 100 &lt;BR /&gt;
3, EUR, 4, 200 &lt;BR /&gt;
3, USD, 1, 300 &lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
                                  &lt;BR /&gt;
ods listing close;&lt;BR /&gt;
ods html file='c:\temp\output\mydata_table.html' style=sasweb;&lt;BR /&gt;
PROC TABULATE data=mydata ; &lt;BR /&gt;
title "Title";&lt;BR /&gt;
class month currency product ;&lt;BR /&gt;
var Amount; &lt;BR /&gt;
table (Month (all='Yearly Total')) *currency *(Product (all='Product Total')) all='Currency Total All Products'*currency all='Yearly Total All Products',&lt;BR /&gt;
      amount /box='Changed Table';&lt;BR /&gt;
                     &lt;BR /&gt;
table month all='Total Month' currency all='Total currency' product all='Total Product'&lt;BR /&gt;
      (month*currency all='Currency and Month Totals')&lt;BR /&gt;
      (month*currency*product all='Currency, Month and Product Totals')&lt;BR /&gt;
      all='Currency Totals'*currency&lt;BR /&gt;
      all='Product totals'*product,&lt;BR /&gt;
      amount / box='Many Different Tables in the Row Dimension';&lt;BR /&gt;
                                                  &lt;BR /&gt;
table (Month (all='Sum_year'))* (Currency (all='Sum'))* (Product (all='Sum')), &lt;BR /&gt;
      Amount / box='Original Table';&lt;BR /&gt;
                                     &lt;BR /&gt;
RUN; &lt;BR /&gt;
ods html close;&lt;BR /&gt;
[/pre]</description>
    <pubDate>Mon, 07 Feb 2011 16:27:56 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2011-02-07T16:27:56Z</dc:date>
    <item>
      <title>Proc tabulate question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-tabulate-question/m-p/69605#M20007</link>
      <description>Hello&lt;BR /&gt;
&lt;BR /&gt;
Please help me with the following. Let's say that I have the following table:&lt;BR /&gt;
&lt;A href="http://img96.imageshack.us/img96/3591/datay.jpg" target="_blank"&gt;http://img96.imageshack.us/img96/3591/datay.jpg&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
I use proc tabulate to create an HTML report:&lt;BR /&gt;
PROC TABULATE data=data ;                                                                                                     title "Title";                                                                                                      class month currency product &lt;BR /&gt;
var Amount;   &lt;BR /&gt;
table (Month (all='Sum_year'))*                                                                                                                       (Currency (all='Sum'))*                                                                                                                       (Product (all='Sum')),                                                                                                     Amount;                                                                                                                                                                                                  &lt;BR /&gt;
RUN;     &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I get the following output table&lt;BR /&gt;
&lt;A href="http://img4.imageshack.us/img4/7752/output1.png" target="_blank"&gt;http://img4.imageshack.us/img4/7752/output1.png&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
As you can see, the "USD" only appears in some months. Is there a way not to print the "sum", where there are no "USD" lines in data-table (in example - month 2).&lt;BR /&gt;
Is there a way not to print the products in the total sum?&lt;BR /&gt;
&lt;BR /&gt;
To make it easier to understand, I have uploaded a picture of how I want my output to look like:&lt;BR /&gt;
&lt;A href="http://img232.imageshack.us/img232/7825/output2.png" target="_blank"&gt;http://img232.imageshack.us/img232/7825/output2.png&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
What do I have to write in Proc tabulate-statement?&lt;BR /&gt;
&lt;BR /&gt;
Thank you!</description>
      <pubDate>Sun, 06 Feb 2011 21:01:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-tabulate-question/m-p/69605#M20007</guid>
      <dc:creator>Alex1</dc:creator>
      <dc:date>2011-02-06T21:01:00Z</dc:date>
    </item>
    <item>
      <title>Re: Proc tabulate question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-tabulate-question/m-p/69606#M20008</link>
      <description>Hi:&lt;BR /&gt;
  As soon as you put&lt;BR /&gt;
&lt;B&gt;* (Currency (all='Sum'))* &lt;/B&gt;&lt;BR /&gt;
into the ROW dimension crossed with MONTH and PRODUCT, you are going to get that summary (ALL) for Currency -- &lt;BR /&gt;
whether you have 1 currency or 10 or 100 currency values in the table. The way TABULATE works is that the table rows for CURRENCY are &lt;BR /&gt;
placed in the row dimension, then you have a space or blank operator and then the ALL -- that means after the CURRENCY rows have been written, &lt;BR /&gt;
the ALL row(s) will be written -- the ALL has no visibility of how many values there were for CURRENCY.&lt;BR /&gt;
 &lt;BR /&gt;
  Possibly reworking your ROW dimension might help you figure out a slightly different approach. Here are two different examples in the code below --&lt;BR /&gt;
 note that there are different TABLE statements so you'll have to scroll down to see the results. The BOX= option was used to provide a name &lt;BR /&gt;
for each table.&lt;BR /&gt;
 &lt;BR /&gt;
And, here are some papers about PROC TABULATE that may help you understand the ALL usage and the space/blank and  * usage a bit better.&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi27/p060-27.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi27/p060-27.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi30/243-30.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi30/243-30.pdf&lt;/A&gt;&lt;BR /&gt;
 &lt;A href="http://www2.sas.com/proceedings/sugi30/258-30.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi30/258-30.pdf&lt;/A&gt;&lt;BR /&gt;
              &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
data mydata;&lt;BR /&gt;
  infile datalines dlm=',' dsd;&lt;BR /&gt;
  input month currency $ product amount;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1, EUR, 1, 100&lt;BR /&gt;
1, USD, 2, 200&lt;BR /&gt;
1, USD, 1, 100&lt;BR /&gt;
1, EUR, 3, 300&lt;BR /&gt;
1, EUR, 4, 400&lt;BR /&gt;
2, EUR, 1, 300&lt;BR /&gt;
2, EUR, 4, 150&lt;BR /&gt;
2, EUR, 3, 150&lt;BR /&gt;
2, EUR, 2, 400&lt;BR /&gt;
2, EUR, 1, 500&lt;BR /&gt;
2, EUR, 2, 100&lt;BR /&gt;
2, EUR, 1, 300&lt;BR /&gt;
3, USD, 4, 100 &lt;BR /&gt;
3, USD, 3, 200 &lt;BR /&gt;
3, EUR, 2, 300 &lt;BR /&gt;
3, EUR, 1, 400  &lt;BR /&gt;
3, USD, 2, 100 &lt;BR /&gt;
3, USD, 3, 100 &lt;BR /&gt;
3, EUR, 4, 200 &lt;BR /&gt;
3, USD, 1, 300 &lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
                                  &lt;BR /&gt;
ods listing close;&lt;BR /&gt;
ods html file='c:\temp\output\mydata_table.html' style=sasweb;&lt;BR /&gt;
PROC TABULATE data=mydata ; &lt;BR /&gt;
title "Title";&lt;BR /&gt;
class month currency product ;&lt;BR /&gt;
var Amount; &lt;BR /&gt;
table (Month (all='Yearly Total')) *currency *(Product (all='Product Total')) all='Currency Total All Products'*currency all='Yearly Total All Products',&lt;BR /&gt;
      amount /box='Changed Table';&lt;BR /&gt;
                     &lt;BR /&gt;
table month all='Total Month' currency all='Total currency' product all='Total Product'&lt;BR /&gt;
      (month*currency all='Currency and Month Totals')&lt;BR /&gt;
      (month*currency*product all='Currency, Month and Product Totals')&lt;BR /&gt;
      all='Currency Totals'*currency&lt;BR /&gt;
      all='Product totals'*product,&lt;BR /&gt;
      amount / box='Many Different Tables in the Row Dimension';&lt;BR /&gt;
                                                  &lt;BR /&gt;
table (Month (all='Sum_year'))* (Currency (all='Sum'))* (Product (all='Sum')), &lt;BR /&gt;
      Amount / box='Original Table';&lt;BR /&gt;
                                     &lt;BR /&gt;
RUN; &lt;BR /&gt;
ods html close;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Mon, 07 Feb 2011 16:27:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-tabulate-question/m-p/69606#M20008</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2011-02-07T16:27:56Z</dc:date>
    </item>
  </channel>
</rss>

