<?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 sums and counts by group/subgroups in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sums-and-counts-by-group-subgroups/m-p/592264#M169799</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm creating a summary table and want to calculate the weighted counts and sums by group and subgroup. I have this summary by subgroups in different files but I want it as 1 summary table, it goes through 2001 to 2017. When I tried to that, I did not get the desired result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;(See excel sheet attached) and my code below&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data=analysis1.in out=analysis1.in_w(drop=_type_);
var weight;
class Year race_sex education;
table Year*race_sex*education
		weight*(n sum);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;</description>
    <pubDate>Fri, 27 Sep 2019 18:20:10 GMT</pubDate>
    <dc:creator>michokwu</dc:creator>
    <dc:date>2019-09-27T18:20:10Z</dc:date>
    <item>
      <title>sums and counts by group/subgroups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sums-and-counts-by-group-subgroups/m-p/592264#M169799</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm creating a summary table and want to calculate the weighted counts and sums by group and subgroup. I have this summary by subgroups in different files but I want it as 1 summary table, it goes through 2001 to 2017. When I tried to that, I did not get the desired result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;(See excel sheet attached) and my code below&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data=analysis1.in out=analysis1.in_w(drop=_type_);
var weight;
class Year race_sex education;
table Year*race_sex*education
		weight*(n sum);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2019 18:20:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sums-and-counts-by-group-subgroups/m-p/592264#M169799</guid>
      <dc:creator>michokwu</dc:creator>
      <dc:date>2019-09-27T18:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: sums and counts by group/subgroups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sums-and-counts-by-group-subgroups/m-p/592273#M169801</link>
      <description>&lt;P&gt;Please supply some example input data in usable form (data step with datelines).&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2019 18:28:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sums-and-counts-by-group-subgroups/m-p/592273#M169801</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-09-27T18:28:02Z</dc:date>
    </item>
    <item>
      <title>Re: sums and counts by group/subgroups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sums-and-counts-by-group-subgroups/m-p/592275#M169803</link>
      <description>&lt;P&gt;Please see Sheet2 attached. Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2019 18:45:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sums-and-counts-by-group-subgroups/m-p/592275#M169803</guid>
      <dc:creator>michokwu</dc:creator>
      <dc:date>2019-09-27T18:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: sums and counts by group/subgroups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sums-and-counts-by-group-subgroups/m-p/592286#M169804</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/255120"&gt;@michokwu&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I'm creating a summary table and want to calculate the weighted counts and sums by group and subgroup. I have this summary by subgroups in different files but I want it as 1 summary table, it goes through 2001 to 2017. When I tried to that, I did not get the desired result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;(See excel sheet attached) and my code below&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data=analysis1.in out=analysis1.in_w(drop=_type_);
var weight;
class Year race_sex education;
table Year*race_sex*education
		weight*(n sum);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You really need to provide an example of the data and what you expect the results for that example data to actually be. We need an actual data set to test code against. Your existing code does not show any attempt to calculate a "weighted count" and I am not sure that&amp;nbsp; you are using the term appropriately.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are not getting the desired result you need to show what the actual desired (or expected) result should be. Other wise have to guess, and with out actual data we can't even guess reasonably.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The way you present your "what I want" does not make a lot of sense with the "count" and "sum" in multiple places. I am moderately sure that Proc tabulate will not line up the columns as shown.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since your have separate tows in our desired output for race_sex and education you do not want to use race_sex*education as the * used that way nests education within race.&lt;/P&gt;
&lt;P&gt;Do you want the "person weight total&lt;/P&gt;
&lt;P&gt;You can get a bit closer with :&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=analysis1.in out=analysis1.in_w(drop=_type_);
   var weight;
   class Year race_sex education;
   table year  weight*(n sum);
   table Year*race_sex
   		weight*(n sum);
   table Year*education
   		weight*(n sum);
run;&lt;/PRE&gt;
&lt;P&gt;But that will not make the columns line up in Excel the way you show. That would be possible with the Report Writing Interface in a data step with appropriate data structure but not with Tabulate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2019 19:32:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sums-and-counts-by-group-subgroups/m-p/592286#M169804</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-09-27T19:32:42Z</dc:date>
    </item>
  </channel>
</rss>

