<?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: Duplicative Group Counting in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Duplicative-Group-Counting/m-p/782047#M81250</link>
    <description>I'm not sure what you mean by the second question, but you can use PROC MEANS or TABULATE and save the output to a data set instead of having it displayed if that's what you're asking about. Use the OUT= option on PROC TABULATE or there are a variety of options with PROC MEANS.&lt;BR /&gt;&lt;BR /&gt;proc tabulate data=have out=AGG_SUMMARY;</description>
    <pubDate>Tue, 23 Nov 2021 18:40:27 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-11-23T18:40:27Z</dc:date>
    <item>
      <title>Duplicative Group Counting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Duplicative-Group-Counting/m-p/782022#M81247</link>
      <description>&lt;P&gt;Hello everyone!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This Forum is just the best for help and hints!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to produce counts and I am having difficulty trying to figure out the logic to code this scenario.&amp;nbsp; I am trying to count individuals by their age as well as produce counts in their age groupings.&amp;nbsp; I am essentially counting each individual twice (once at their actual age and then again in an age grouping category)&amp;nbsp; My SAS code seem to capture the record once and I cannot figure out a way to count the record twice.&amp;nbsp; Any help or advice would be greatly appreciated.&amp;nbsp; I have included sample data and a results table in which I would like to see the counts.&amp;nbsp; The results table under the Age column will reflect the age of (ID) as well as counted again in the age grouping.&amp;nbsp; For example, ID=SJ990 is counted once under age (12) and then again under age (10-15) under the Count column.&amp;nbsp; Can anyone assist me with figuring out how I can achieve this?&amp;nbsp; Thank you in advance!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="192"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD colspan="2" width="128"&gt;Sample Data Table&lt;/TD&gt;
&lt;TD width="64"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;ID&lt;/TD&gt;
&lt;TD&gt;age&lt;/TD&gt;
&lt;TD&gt;location&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;SJ990&lt;/TD&gt;
&lt;TD&gt;12&lt;/TD&gt;
&lt;TD&gt;R119&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;MR213&lt;/TD&gt;
&lt;TD&gt;17&lt;/TD&gt;
&lt;TD&gt;R119&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;SS913&lt;/TD&gt;
&lt;TD&gt;17&lt;/TD&gt;
&lt;TD&gt;B099&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;AT893&lt;/TD&gt;
&lt;TD&gt;11&lt;/TD&gt;
&lt;TD&gt;B099&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;TL332&lt;/TD&gt;
&lt;TD&gt;22&lt;/TD&gt;
&lt;TD&gt;B099&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD colspan="2"&gt;Results Table&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Age&lt;/TD&gt;
&lt;TD&gt;Count&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;11&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;12&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;17&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;22&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;10-15&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;16-22&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Tue, 23 Nov 2021 17:40:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Duplicative-Group-Counting/m-p/782022#M81247</guid>
      <dc:creator>SannaSanna</dc:creator>
      <dc:date>2021-11-23T17:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicative Group Counting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Duplicative-Group-Counting/m-p/782026#M81248</link>
      <description>&lt;P&gt;SAS supports this using Multilabel Formats.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rough idea:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value age_mlf_fmt (multilabel)
10 = 10
11 = 11
12 = 12
13 = 13 
....
10-15 = '10 - 15'
16-22 = '16 - 22';
run;

proc tabulate data=have;
class age / mlf;
format age age_mlf_fmt.;
table age;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Tested fully worked exmaple:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://gist.github.com/statgeek/1c6f38ef368a4272cf458b017fc63d4b" target="_blank"&gt;https://gist.github.com/statgeek/1c6f38ef368a4272cf458b017fc63d4b&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12130"&gt;@SannaSanna&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello everyone!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This Forum is just the best for help and hints!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to produce counts and I am having difficulty trying to figure out the logic to code this scenario.&amp;nbsp; I am trying to count individuals by their age as well as produce counts in their age groupings.&amp;nbsp; I am essentially counting each individual twice (once at their actual age and then again in an age grouping category)&amp;nbsp; My SAS code seem to capture the record once and I cannot figure out a way to count the record twice.&amp;nbsp; Any help or advice would be greatly appreciated.&amp;nbsp; I have included sample data and a results table in which I would like to see the counts.&amp;nbsp; The results table under the Age column will reflect the age of (ID) as well as counted again in the age grouping.&amp;nbsp; For example, ID=SJ990 is counted once under age (12) and then again under age (10-15) under the Count column.&amp;nbsp; Can anyone assist me with figuring out how I can achieve this?&amp;nbsp; Thank you in advance!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="192"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt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amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;12&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;17&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;22&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;10-15&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;16-22&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Nov 2021 17:46:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Duplicative-Group-Counting/m-p/782026#M81248</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-23T17:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicative Group Counting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Duplicative-Group-Counting/m-p/782033#M81249</link>
      <description>Thank you Reeza!   Is there a way I can use the aggregated count record rows for further processing?  I would like to run further cross tabulations on and want to use the column 'Age' with the aggregated groupings (meaning counting the individuals age as well as counting them again in the aggregated form) to get further results?</description>
      <pubDate>Tue, 23 Nov 2021 18:08:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Duplicative-Group-Counting/m-p/782033#M81249</guid>
      <dc:creator>SannaSanna</dc:creator>
      <dc:date>2021-11-23T18:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicative Group Counting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Duplicative-Group-Counting/m-p/782047#M81250</link>
      <description>I'm not sure what you mean by the second question, but you can use PROC MEANS or TABULATE and save the output to a data set instead of having it displayed if that's what you're asking about. Use the OUT= option on PROC TABULATE or there are a variety of options with PROC MEANS.&lt;BR /&gt;&lt;BR /&gt;proc tabulate data=have out=AGG_SUMMARY;</description>
      <pubDate>Tue, 23 Nov 2021 18:40:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Duplicative-Group-Counting/m-p/782047#M81250</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-23T18:40:27Z</dc:date>
    </item>
  </channel>
</rss>

