<?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 aggregating frequencies in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/aggregating-frequencies/m-p/393962#M277882</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a question about aggregating frequencies. In short, each observation has a family ID and a marker that says if the observation is for an adult or a child. (example data below). NOTE: the real dataset included 1000s of families.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FamID adlt chld&lt;BR /&gt;001 &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;001 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;001 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;002 &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;002 &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;002 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;002 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;002 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;002 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;003 &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;003 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;003 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;004 &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; 0&amp;nbsp;&lt;BR /&gt;004 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;004 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to determine how many families have 1 child, or 2 children, etc...&lt;/P&gt;&lt;P&gt;The output should look like the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#Child &amp;nbsp; #families&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone offer advise on how to approach this? I tried the following without success:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SUMMARY data=in;&lt;BR /&gt;class FamID;&lt;BR /&gt;var chld adlt;&lt;BR /&gt;output out=agg sum=chld adlt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC TABULATE data=in;&lt;BR /&gt;class FamID;&lt;BR /&gt;var chld;&lt;BR /&gt;table chld;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm sure that I'm overthinking this, but I'm stuck. Any help would be appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Sep 2017 17:26:29 GMT</pubDate>
    <dc:creator>MillerEL</dc:creator>
    <dc:date>2017-09-07T17:26:29Z</dc:date>
    <item>
      <title>aggregating frequencies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/aggregating-frequencies/m-p/393962#M277882</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a question about aggregating frequencies. In short, each observation has a family ID and a marker that says if the observation is for an adult or a child. (example data below). NOTE: the real dataset included 1000s of families.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FamID adlt chld&lt;BR /&gt;001 &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;001 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;001 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;002 &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;002 &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;002 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;002 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;002 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;002 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;003 &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;003 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;003 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;004 &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; 0&amp;nbsp;&lt;BR /&gt;004 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;004 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to determine how many families have 1 child, or 2 children, etc...&lt;/P&gt;&lt;P&gt;The output should look like the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#Child &amp;nbsp; #families&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone offer advise on how to approach this? I tried the following without success:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SUMMARY data=in;&lt;BR /&gt;class FamID;&lt;BR /&gt;var chld adlt;&lt;BR /&gt;output out=agg sum=chld adlt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC TABULATE data=in;&lt;BR /&gt;class FamID;&lt;BR /&gt;var chld;&lt;BR /&gt;table chld;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm sure that I'm overthinking this, but I'm stuck. Any help would be appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 17:26:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/aggregating-frequencies/m-p/393962#M277882</guid>
      <dc:creator>MillerEL</dc:creator>
      <dc:date>2017-09-07T17:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: aggregating frequencies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/aggregating-frequencies/m-p/393966#M277883</link>
      <description>&lt;P&gt;Your approach is correct, but the data for proc tabulate should be the output from the PROC SUMMARY not the original data set.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The logic is essentially:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Find the number of kids per family - add child numbers using PROC SUMMARY&lt;/P&gt;
&lt;P&gt;2. Summarize data from Step 1 using PROC FREQ or PROC TABULATE. Note that you don't want the CLASS variable in the PROC TABULATE because you're counting overall, not by FAMILY ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 17:29:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/aggregating-frequencies/m-p/393966#M277883</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-07T17:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: aggregating frequencies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/aggregating-frequencies/m-p/393969#M277884</link>
      <description>&lt;P&gt;Many ways to skin this cat ... I tend to favor PROC FREQ for counting.&amp;nbsp; Start by adding NWAY to the end of your PROC SUMMARY statement.&amp;nbsp; Then continue:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=AGG;&lt;/P&gt;
&lt;P&gt;tables chld;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The CHLD column is the number of children, and the FREQUENCY column is the number of families having that number of&amp;nbsp;children.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 17:42:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/aggregating-frequencies/m-p/393969#M277884</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-09-07T17:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: aggregating frequencies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/aggregating-frequencies/m-p/393982#M277885</link>
      <description>&lt;P&gt;Perfect. Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 18:11:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/aggregating-frequencies/m-p/393982#M277885</guid>
      <dc:creator>MillerEL</dc:creator>
      <dc:date>2017-09-07T18:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: aggregating frequencies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/aggregating-frequencies/m-p/393983#M277886</link>
      <description>Perfect! Thank you!&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Sep 2017 18:11:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/aggregating-frequencies/m-p/393983#M277886</guid>
      <dc:creator>MillerEL</dc:creator>
      <dc:date>2017-09-07T18:11:33Z</dc:date>
    </item>
  </channel>
</rss>

