<?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: Count by Variable Groups in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Count-by-Variable-Groups/m-p/520877#M141275</link>
    <description>&lt;P&gt;Post sample data please, fake data is fine.&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/151600"&gt;@Barkamih&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Sure, that is my issue. For example, the county is repeated many times by year, as well as herds are repeated by year for each county. So in this case what is the code looks like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;regards&amp;nbsp;&lt;/P&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>Wed, 12 Dec 2018 16:03:29 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-12-12T16:03:29Z</dc:date>
    <item>
      <title>Count by Variable Groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-by-Variable-Groups/m-p/520812#M141259</link>
      <description>&lt;P&gt;Hi all&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to know if this code is correct for my question.&lt;/P&gt;&lt;P&gt;I want to know the number of herds in each month for each county by using this code.&lt;/P&gt;&lt;P&gt;regards&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ibrahim&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc freq data = have;
tables month*county*herd / out = want;
run; quit; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Dec 2018 14:04:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-by-Variable-Groups/m-p/520812#M141259</guid>
      <dc:creator>Barkamih</dc:creator>
      <dc:date>2018-12-12T14:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: Count by Variable Groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-by-Variable-Groups/m-p/520813#M141260</link>
      <description>&lt;P&gt;So long as the&amp;nbsp;by groups are in order (I would guess):&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;freq&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;have&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;  tables&lt;/SPAN&gt; county&lt;SPAN class="token operator"&gt;*month*&lt;/SPAN&gt;herd &lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt; out&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;want&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Note you don't need the quit;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 14:06:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-by-Variable-Groups/m-p/520813#M141260</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-12T14:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: Count by Variable Groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-by-Variable-Groups/m-p/520814#M141261</link>
      <description>&lt;P&gt;No, not quite.&amp;nbsp; It tells you number of times each herd appeared in each month/county.&amp;nbsp; You would have to continue with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=want;&lt;/P&gt;
&lt;P&gt;tables month*county / out=truly_want;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That summarizes to the counts that you are looking for:&amp;nbsp; number of herds for each month/county.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 14:13:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-by-Variable-Groups/m-p/520814#M141261</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-12-12T14:13:07Z</dc:date>
    </item>
    <item>
      <title>Re: Count by Variable Groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-by-Variable-Groups/m-p/520865#M141273</link>
      <description>&lt;P&gt;It depends on your data structure and data. If you have repeated measurements the answer is different than if you have a single list of entries.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 15:51:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-by-Variable-Groups/m-p/520865#M141273</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-12T15:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: Count by Variable Groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-by-Variable-Groups/m-p/520868#M141274</link>
      <description>&lt;P&gt;Sure, that is my issue. For example, the county is repeated many times by year, as well as herds are repeated by year for each county. So in this case what is the code looks like?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 15:59:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-by-Variable-Groups/m-p/520868#M141274</guid>
      <dc:creator>Barkamih</dc:creator>
      <dc:date>2018-12-12T15:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: Count by Variable Groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-by-Variable-Groups/m-p/520877#M141275</link>
      <description>&lt;P&gt;Post sample data please, fake data is fine.&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/151600"&gt;@Barkamih&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Sure, that is my issue. For example, the county is repeated many times by year, as well as herds are repeated by year for each county. So in this case what is the code looks like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;regards&amp;nbsp;&lt;/P&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>Wed, 12 Dec 2018 16:03:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-by-Variable-Groups/m-p/520877#M141275</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-12T16:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: Count by Variable Groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-by-Variable-Groups/m-p/520883#M141280</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;herd	     County	month	YEAR
59994724	Lim	3	2004
59994724	Lim	7	2004
59994724	Lim	4	2004
59994724	Lim	8	2004
59994724	Lim	9	2004
59994724	Lim	5	2004
59994724	Lim	6	2004
59994724	Lim	7	2005
59994724	Lim	10	2005
59994724	Lim	9	2005
59994724	Lim	12	2005
59994724	Lim	6	2005
59994724	Lim	8	2005
59994724	Lim	11	2005
59994724	Lim	8	2004
59994724	Lim	7	2004
59994724	Lim	6	2004
59994724	Lim	2	2004
59994724	Lim	5	2004
59994724	Lim	4	2004
59994724	Lim	2	2005
59994724	Lim	3	2005
59994724	Lim	5	2005
59994724	Lim	10	2005
59994724	Lim	9	2005
59994724	Lim	8	2005
59994724	Lim	7	2005
59994724	Lim	6	2005
60005584	Co	4	2004
60005584	Co	5	2004
60005584	Co	6	2004
60005584	Co	10	2004
60005584	Co	8	2004
60005584	Co	9	2004
60006084	Co	10	2004
60006084	Co	7	2004
60006084	Co	11	2004
60006084	Co	4	2004
60006084	Co	9	2004&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Dec 2018 16:12:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-by-Variable-Groups/m-p/520883#M141280</guid>
      <dc:creator>Barkamih</dc:creator>
      <dc:date>2018-12-12T16:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: Count by Variable Groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-by-Variable-Groups/m-p/520889#M141283</link>
      <description>&lt;PRE&gt;proc sql;
create table want as
select county, month, year, count(distinct herd) as n_herd
from have
group by county, month, year;
quit;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/151600"&gt;@Barkamih&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;herd	     County	month	YEAR
59994724	Lim	3	2004
59994724	Lim	7	2004
59994724	Lim	4	2004
59994724	Lim	8	2004
59994724	Lim	9	2004
59994724	Lim	5	2004
59994724	Lim	6	2004
59994724	Lim	7	2005
59994724	Lim	10	2005
59994724	Lim	9	2005
59994724	Lim	12	2005
59994724	Lim	6	2005
59994724	Lim	8	2005
59994724	Lim	11	2005
59994724	Lim	8	2004
59994724	Lim	7	2004
59994724	Lim	6	2004
59994724	Lim	2	2004
59994724	Lim	5	2004
59994724	Lim	4	2004
59994724	Lim	2	2005
59994724	Lim	3	2005
59994724	Lim	5	2005
59994724	Lim	10	2005
59994724	Lim	9	2005
59994724	Lim	8	2005
59994724	Lim	7	2005
59994724	Lim	6	2005
60005584	Co	4	2004
60005584	Co	5	2004
60005584	Co	6	2004
60005584	Co	10	2004
60005584	Co	8	2004
60005584	Co	9	2004
60006084	Co	10	2004
60006084	Co	7	2004
60006084	Co	11	2004
60006084	Co	4	2004
60006084	Co	9	2004&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 16:23:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-by-Variable-Groups/m-p/520889#M141283</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-12T16:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: Count by Variable Groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-by-Variable-Groups/m-p/520904#M141289</link>
      <description>thanks very much my friend&lt;BR /&gt;I appreciate it&lt;BR /&gt;best regards&lt;BR /&gt;&lt;BR /&gt;Ibrahim</description>
      <pubDate>Wed, 12 Dec 2018 16:52:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-by-Variable-Groups/m-p/520904#M141289</guid>
      <dc:creator>Barkamih</dc:creator>
      <dc:date>2018-12-12T16:52:52Z</dc:date>
    </item>
  </channel>
</rss>

