<?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-Percentage from overall sum in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-Percentage-from-overall-sum/m-p/457306#M115935</link>
    <description>&lt;P&gt;Looks like you have 5 questions here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some of these are easy.&amp;nbsp; Do you have access to the documentation?&amp;nbsp; To label variables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;table country,product='Product Name'*actual='Sales'*pctsum/box="Country Name";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly, to add a % sign use a format (but there may be a drawback):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;table country,product*actual*pctsum*f=percent9.2/box="Country Name";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The drawback:&amp;nbsp; the percent format expects numbers between 0 and 1.&amp;nbsp; You may have to add a multiplier (uh-oh, have to read the documentation here).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get row or column totals, PROC TABULATE uses the keyword ALL (uh-oh again, have to read the documentation).&amp;nbsp; Something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;table country all,(product*actual all)*pctsum/box="Country Name";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may need to fiddle with it to get it to come out right.&amp;nbsp; Also note, it's not clear why you would want totals for both rows and columns.&amp;nbsp; Wouldn't some of those totals have to be 100%?&amp;nbsp; You haven't really shown what the final report should look like, but you're likely to go through a few tests, experiments, and iterations until it comes out the way you want it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;********************* EDITED:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looks like Cynthia and I were composing our responses at the same time.&amp;nbsp; Trust whatever &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp;says on this ... she's the expert when it comes to PROC TABULATE.&lt;/P&gt;</description>
    <pubDate>Wed, 25 Apr 2018 14:28:30 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-04-25T14:28:30Z</dc:date>
    <item>
      <title>proc tabulate-Percentage from overall sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-Percentage-from-overall-sum/m-p/457183#M115893</link>
      <description>&lt;P&gt;Hello friends&lt;/P&gt;&lt;P&gt;I have a question please.&lt;/P&gt;&lt;P&gt;I run the following code.&lt;/P&gt;&lt;P&gt;I want to display values with % symbol.&lt;/P&gt;&lt;P&gt;I want also to add Totals in each column .&lt;/P&gt;&lt;P&gt;I want also to add Totals in each Row&amp;nbsp;.&lt;/P&gt;&lt;P&gt;I want to modify header "product" to "Product Name".&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want to modify header "Actual sales" &amp;nbsp;to "Sales".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Can anyone help to modify the code to get it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc tabulate data=sashelp.prdsale;&lt;BR /&gt;class country product;&lt;BR /&gt;var actual;&lt;BR /&gt;table country,product*actual*pctsum/box="Country Name";&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Apr 2018 08:34:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-Percentage-from-overall-sum/m-p/457183#M115893</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-04-25T08:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate-Percentage from overall sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-Percentage-from-overall-sum/m-p/457188#M115895</link>
      <description>&lt;P&gt;As you have not provided test data in the form of a datastep and what the output should look like this will be vague.&amp;nbsp; You can look at the various papers out there and the documentation:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/sugi24/Handson/p153-24.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi24/Handson/p153-24.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/forum2008/264-2008.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2008/264-2008.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;(Note, whilst I put links to those documents I would strongly advise not to code all in uppercase like they show, and to finish blocks off with run; statements.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To display values with a percentage sign you use the format statement.&lt;/P&gt;
&lt;P&gt;Headers you use the title statement.&lt;/P&gt;
&lt;P&gt;Totals, its a matter of putting the (sum) statistic in the place you want it.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Apr 2018 09:04:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-Percentage-from-overall-sum/m-p/457188#M115895</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-25T09:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate-Percentage from overall sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-Percentage-from-overall-sum/m-p/457301#M115932</link>
      <description>&lt;P&gt;Hi:&amp;nbsp; &lt;BR /&gt;I like this paper on TABULATE:&lt;BR /&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings11/173-2011.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings11/173-2011.pdf&lt;/A&gt; and the one listed below that is specifically about percentages.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I want to display values with % symbol.&lt;BR /&gt;&amp;gt;&amp;gt; Investigate the use of a PICTURE format as shown on page 12 of this paper: &lt;A href="https://support.sas.com/resources/papers/proceedings13/134-2013.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings13/134-2013.pdf&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I want also to add Totals in each column .&lt;BR /&gt;I want also to add Totals in each Row .&lt;BR /&gt;&amp;gt;&amp;gt; Do you want row percents? (every row adds up to 100)&lt;BR /&gt;&amp;gt;&amp;gt; Do you want column percents? (every column adds up to 100)&lt;BR /&gt;&amp;gt;&amp;gt; Do you want percent of the grand total (lower right cell adds up to 100)&lt;BR /&gt;(see pages 16 and 17 in this &lt;A href="http://support.sas.com/resources/papers/proceedings11/173-2011.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings11/173-2011.pdf&lt;/A&gt;)&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;gt;&amp;gt; to get a final Total Row at the bottom of the other rows, &lt;BR /&gt;&amp;nbsp;&amp;nbsp; you specify ALL in the TABLE statement for the ROW dimension (see page 5 in this paper &lt;A href="http://support.sas.com/resources/papers/proceedings11/173-2011.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings11/173-2011.pdf&lt;/A&gt; )&lt;BR /&gt;&lt;BR /&gt;I want to modify header "product" to "Product Name".&lt;BR /&gt;I want to modify header "Actual sales"&amp;nbsp; to "Sales".&lt;BR /&gt;&amp;gt;&amp;gt; Investigate how to use a label in the TABLE Statement&lt;BR /&gt;&amp;gt;&amp;gt; and how to use the KEYLABEL statement&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;There have been previous postings on the use of PROC TABULATE, you might find some examples if you search. &lt;BR /&gt;&lt;BR /&gt;Hope this points you in a useful direction.&lt;BR /&gt;&lt;BR /&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Wed, 25 Apr 2018 14:19:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-Percentage-from-overall-sum/m-p/457301#M115932</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2018-04-25T14:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate-Percentage from overall sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-Percentage-from-overall-sum/m-p/457306#M115935</link>
      <description>&lt;P&gt;Looks like you have 5 questions here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some of these are easy.&amp;nbsp; Do you have access to the documentation?&amp;nbsp; To label variables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;table country,product='Product Name'*actual='Sales'*pctsum/box="Country Name";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly, to add a % sign use a format (but there may be a drawback):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;table country,product*actual*pctsum*f=percent9.2/box="Country Name";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The drawback:&amp;nbsp; the percent format expects numbers between 0 and 1.&amp;nbsp; You may have to add a multiplier (uh-oh, have to read the documentation here).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get row or column totals, PROC TABULATE uses the keyword ALL (uh-oh again, have to read the documentation).&amp;nbsp; Something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;table country all,(product*actual all)*pctsum/box="Country Name";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may need to fiddle with it to get it to come out right.&amp;nbsp; Also note, it's not clear why you would want totals for both rows and columns.&amp;nbsp; Wouldn't some of those totals have to be 100%?&amp;nbsp; You haven't really shown what the final report should look like, but you're likely to go through a few tests, experiments, and iterations until it comes out the way you want it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;********************* EDITED:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looks like Cynthia and I were composing our responses at the same time.&amp;nbsp; Trust whatever &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp;says on this ... she's the expert when it comes to PROC TABULATE.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Apr 2018 14:28:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-Percentage-from-overall-sum/m-p/457306#M115935</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-04-25T14:28:30Z</dc:date>
    </item>
  </channel>
</rss>

