<?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: Calculating percentage in proc means or proc report or proc tabulate in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Calculating-percentage-in-proc-means-or-proc-report-or-proc/m-p/373038#M65200</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am not having anything in my input data which tells me about sum I calculated it by proc measn&lt;/P&gt;&lt;P&gt;The solution you provided contains sales data but in my data I dont have it (rather I have to calculate it)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i am attaching input file in the attachment&lt;/P&gt;&lt;P&gt;PLEASE IGNORE MISSING VALUES&lt;/P&gt;</description>
    <pubDate>Tue, 04 Jul 2017 15:39:30 GMT</pubDate>
    <dc:creator>Nishant_saxena</dc:creator>
    <dc:date>2017-07-04T15:39:30Z</dc:date>
    <item>
      <title>Calculating percentage in proc means or proc report or proc tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculating-percentage-in-proc-means-or-proc-report-or-proc/m-p/373000#M65195</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I am stucked here:&lt;/P&gt;&lt;P&gt;My code is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc means data=final_file_distance sum;&lt;BR /&gt;class store_postcode;&lt;BR /&gt;var retail_price;&lt;BR /&gt;output out=rs2;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output is attached in attachment.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What /I want is :&lt;/P&gt;&lt;P&gt;(1) to calculate overall sum of " sum" column as total_sale&lt;/P&gt;&lt;P&gt;(2) PErcentage of sale for every StorePostcode &amp;nbsp; (i.e sum/total_sale)% for individual StorePostcode&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/14028i4316152D30DC806A/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="output1.PNG" title="output1.PNG" /&gt;</description>
      <pubDate>Tue, 04 Jul 2017 13:55:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculating-percentage-in-proc-means-or-proc-report-or-proc/m-p/373000#M65195</guid>
      <dc:creator>Nishant_saxena</dc:creator>
      <dc:date>2017-07-04T13:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentage in proc means or proc report or proc tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculating-percentage-in-proc-means-or-proc-report-or-proc/m-p/373021#M65198</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; You do not need to run PROC MEANS first. Either PROC TABULATE or PROC REPORT would give you the percentages you want. You showed the output from PROC MEANS, not your desired output. And, you did not post the input data, but take a look at SASHELP.SHOES -- that has regions and sales. So either of these procedures would work: &lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10117i5FB30A525120BDD0/image-size/original?v=1.0&amp;amp;px=-1" alt="pct_tab_report.png" title="pct_tab_report.png" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For what you want to do, either of these procedures can summarize, like PROC MEANS and then calculate the percentage without making an extra pass through the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cynthia&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jul 2017 14:40:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculating-percentage-in-proc-means-or-proc-report-or-proc/m-p/373021#M65198</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-07-04T14:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentage in proc means or proc report or proc tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculating-percentage-in-proc-means-or-proc-report-or-proc/m-p/373038#M65200</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am not having anything in my input data which tells me about sum I calculated it by proc measn&lt;/P&gt;&lt;P&gt;The solution you provided contains sales data but in my data I dont have it (rather I have to calculate it)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i am attaching input file in the attachment&lt;/P&gt;&lt;P&gt;PLEASE IGNORE MISSING VALUES&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jul 2017 15:39:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculating-percentage-in-proc-means-or-proc-report-or-proc/m-p/373038#M65200</guid>
      <dc:creator>Nishant_saxena</dc:creator>
      <dc:date>2017-07-04T15:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentage in proc means or proc report or proc tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculating-percentage-in-proc-means-or-proc-report-or-proc/m-p/373050#M65202</link>
      <description>&lt;P&gt;Sorry, I don't open Excel files. It is better to post your data in a DATA step program that anyone can read as a text file.&lt;BR /&gt;&lt;BR /&gt;In my example, SASHELP.SHOES has a variable called SALES, in your example, you have a variable called RETAIL_PRICE.&lt;BR /&gt;&lt;BR /&gt;Your PROC MEANS code is giving your results the SUM or RETAIL_PRICE grouped by the class variable STORE_POSTCODE.&lt;BR /&gt;&lt;BR /&gt;In my examples, SALES is the equivalent of your variable RETAIL_PRICE and REGION is the equivalent of STORE_POSTCODE. In SASHELP.SHOES there are multiple sales for every REGION, so both REPORT and TABULATE are summarizing and calculating percent. Notice in the screen shot below (still using SASHELP.SHOES) how the sum of SALES for each region is the same whether you use PROC MEANS, PROC REPORT or PROC TABULATE. Then notice how the grand total of the SALES figure is the same. Notice how the percents calculate by REPORT and TABULATE are the same.&lt;BR /&gt;&lt;BR /&gt;PROC MEANS will provide you with the overall GRAND TOTAL for your RETAIL_PRICE variable, but not in the most usable way possible. READ in the documentation about the use of the _TYPE_ automatic variable. Personally, I find using TABULATE or REPORT much easier than PROC MEANS for sums and percents.&lt;BR /&gt; &lt;BR /&gt;cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10119i37D7B4D5720D3FBA/image-size/original?v=1.0&amp;amp;px=-1" alt="revised_to_show_sum.png" title="revised_to_show_sum.png" border="0" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jul 2017 19:58:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculating-percentage-in-proc-means-or-proc-report-or-proc/m-p/373050#M65202</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-07-04T19:58:29Z</dc:date>
    </item>
  </channel>
</rss>

