<?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: How to get each member's % of their group total in a new variable? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-each-member-s-of-their-group-total-in-a-new-variable/m-p/441067#M69244</link>
    <description>&lt;P&gt;Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt; and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; , for your time and brain cycles.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp; Awesome! I really appreciate that you&amp;nbsp;wrote this beautiful code. It works fine and I'll spend some time "studying" it. Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;Thank you for this suggestion. I'll definitely look into it while reverse engineering Astounding's code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My respects!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Feb 2018 23:09:06 GMT</pubDate>
    <dc:creator>mragaa</dc:creator>
    <dc:date>2018-02-28T23:09:06Z</dc:date>
    <item>
      <title>How to get each member's % of their group total in a new variable?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-each-member-s-of-their-group-total-in-a-new-variable/m-p/440979#M69236</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The challenge: I have the sales and region&amp;nbsp;of each store. I wanna calculate each store's percentage sales of its region's total and add this result as a new variable in the dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I have so far: I'm assuming this is solvable by PROC SQL yet, as you can probably guess&amp;nbsp; now, my SQL skills are newbie-level. I only got this far (from another thread &lt;A href="https://communities.sas.com/t5/SAS-Procedures/sums-and-counts-by-group/td-p/49055" target="_self"&gt;here&lt;/A&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;SELECT Region, COUNT(storeID), SUM(Sales)&lt;BR /&gt;FROM sample&amp;nbsp;&lt;BR /&gt;GROUP BY Region&lt;BR /&gt;ORDER BY Region;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm attaching a sample of the data for your convenience. I'm using SAS 9.4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 18:10:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-each-member-s-of-their-group-total-in-a-new-variable/m-p/440979#M69236</guid>
      <dc:creator>mragaa</dc:creator>
      <dc:date>2018-02-28T18:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to get each member's % of their group total in a new variable?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-each-member-s-of-their-group-total-in-a-new-variable/m-p/440984#M69237</link>
      <description>&lt;P&gt;Try PROC FREQ instead with the default output data set.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 18:24:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-each-member-s-of-their-group-total-in-a-new-variable/m-p/440984#M69237</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-28T18:24:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to get each member's % of their group total in a new variable?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-each-member-s-of-their-group-total-in-a-new-variable/m-p/440993#M69238</link>
      <description>&lt;P&gt;Since you are adding the variable to the data set, I would go with a DATA step.&amp;nbsp; As long as each store has a single observation, there are no complications.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have;&lt;/P&gt;
&lt;P&gt;by region;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;tot_sales=0;&lt;/P&gt;
&lt;P&gt;do until (last.region);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by region;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; tot_sales + sales;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;do until (last.region);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by region;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; pct_sales = sales / tot_sales;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;drop tot_sales;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 19:10:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-each-member-s-of-their-group-total-in-a-new-variable/m-p/440993#M69238</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-28T19:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to get each member's % of their group total in a new variable?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-each-member-s-of-their-group-total-in-a-new-variable/m-p/441067#M69244</link>
      <description>&lt;P&gt;Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt; and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; , for your time and brain cycles.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp; Awesome! I really appreciate that you&amp;nbsp;wrote this beautiful code. It works fine and I'll spend some time "studying" it. Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;Thank you for this suggestion. I'll definitely look into it while reverse engineering Astounding's code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My respects!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 23:09:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-each-member-s-of-their-group-total-in-a-new-variable/m-p/441067#M69244</guid>
      <dc:creator>mragaa</dc:creator>
      <dc:date>2018-02-28T23:09:06Z</dc:date>
    </item>
  </channel>
</rss>

