<?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 Group by Month and Year and Count by Name field in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Month-and-Year-and-Count-by-Name-field/m-p/507434#M136209</link>
    <description>&lt;P&gt;Hi I was hoping someone can help, I have a data set with millions of lines and I want to group count by name field and group by date, However the date field currently has the day in there as well&amp;nbsp; current format for the date field in the table is YYMMDD8, see some sample data below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Name&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date&lt;/P&gt;&lt;P&gt;54642 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;18-08-31&lt;/P&gt;&lt;P&gt;217233&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;18-08-15&lt;/P&gt;&lt;P&gt;502368&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 18-08-09&lt;/P&gt;&lt;P&gt;541562&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 16-08-31&lt;/P&gt;&lt;P&gt;553023&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 16-08-09&lt;/P&gt;&lt;P&gt;577616 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 17-05-31&lt;/P&gt;&lt;P&gt;601365&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 15-06-31&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind Regards&lt;/P&gt;&lt;P&gt;Zuneid&lt;/P&gt;</description>
    <pubDate>Thu, 25 Oct 2018 09:23:19 GMT</pubDate>
    <dc:creator>zdassu</dc:creator>
    <dc:date>2018-10-25T09:23:19Z</dc:date>
    <item>
      <title>Group by Month and Year and Count by Name field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Month-and-Year-and-Count-by-Name-field/m-p/507434#M136209</link>
      <description>&lt;P&gt;Hi I was hoping someone can help, I have a data set with millions of lines and I want to group count by name field and group by date, However the date field currently has the day in there as well&amp;nbsp; current format for the date field in the table is YYMMDD8, see some sample data below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Name&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date&lt;/P&gt;&lt;P&gt;54642 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;18-08-31&lt;/P&gt;&lt;P&gt;217233&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;18-08-15&lt;/P&gt;&lt;P&gt;502368&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 18-08-09&lt;/P&gt;&lt;P&gt;541562&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 16-08-31&lt;/P&gt;&lt;P&gt;553023&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 16-08-09&lt;/P&gt;&lt;P&gt;577616 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 17-05-31&lt;/P&gt;&lt;P&gt;601365&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 15-06-31&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind Regards&lt;/P&gt;&lt;P&gt;Zuneid&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 09:23:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Month-and-Year-and-Count-by-Name-field/m-p/507434#M136209</guid>
      <dc:creator>zdassu</dc:creator>
      <dc:date>2018-10-25T09:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: Group by Month and Year and Count by Name field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Month-and-Year-and-Count-by-Name-field/m-p/507436#M136210</link>
      <description>&lt;P&gt;A date always has a day, or it wouldn't be a date.&lt;/P&gt;
&lt;P&gt;This should do it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select name, date, count(*) as count
from have
group by name, date;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or use proc summary with statistic N.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 09:34:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Month-and-Year-and-Count-by-Name-field/m-p/507436#M136210</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-25T09:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: Group by Month and Year and Count by Name field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Month-and-Year-and-Count-by-Name-field/m-p/507437#M136211</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/59173"&gt;@zdassu&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the crucial point is to apply a format to variable Date that&amp;nbsp;aggregates dates&amp;nbsp;to months, for example YYMMD5.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can do this in PROC SQL as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;has suggested&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select name, put(date,yymmd5.) as month, count(*) as count
from have
group by name, month;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but also in PROC FREQ, PROC SUMMARY and other procedures:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have noprint;
format date yymmd5.;
tables name*date / out=want(drop=percent);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Oct 2018 09:55:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Month-and-Year-and-Count-by-Name-field/m-p/507437#M136211</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-25T09:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: Group by Month and Year and Count by Name field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Month-and-Year-and-Count-by-Name-field/m-p/507439#M136212</link>
      <description>&lt;P&gt;Thanks for your help but how do I count all records in name for say Oct 2008 and so on&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 10:03:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Month-and-Year-and-Count-by-Name-field/m-p/507439#M136212</guid>
      <dc:creator>zdassu</dc:creator>
      <dc:date>2018-10-25T10:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: Group by Month and Year and Count by Name field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Month-and-Year-and-Count-by-Name-field/m-p/507440#M136213</link>
      <description>&lt;P&gt;Thanks for your help but how do I count all records in name for say Oct 2008 and so on, so the results look like the below&lt;/P&gt;&lt;P&gt;Name&amp;nbsp; &amp;nbsp;date&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Oct 2008&lt;/P&gt;&lt;P&gt;7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Nov 2008&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 10:07:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Month-and-Year-and-Count-by-Name-field/m-p/507440#M136213</guid>
      <dc:creator>zdassu</dc:creator>
      <dc:date>2018-10-25T10:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: Group by Month and Year and Count by Name field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Month-and-Year-and-Count-by-Name-field/m-p/507441#M136214</link>
      <description>&lt;P&gt;Just use a different format, e.g. MONYY7., or combine month and year components like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select name, catx(' ',put(date,monname3.),year(date)) as month length=8, count(*) as count&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in the PROC SQL solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: Here with another format for the PROC FREQ solution:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options locale=English_UnitedStates;
proc freq data=have noprint;
format date nldateymm.;
tables name*date / out=want(drop=percent);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Oct 2018 10:31:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Month-and-Year-and-Count-by-Name-field/m-p/507441#M136214</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-25T10:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: Group by Month and Year and Count by Name field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Month-and-Year-and-Count-by-Name-field/m-p/507447#M136218</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/59173"&gt;@zdassu&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for your help but how do I count all records in name for say Oct 2008 and so on&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I haven't looked to close at the code &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt; posted, but imho it does exactly what you want: count by name, year and month. If you want something else, please post the expected result from the input you have posted.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 10:52:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Month-and-Year-and-Count-by-Name-field/m-p/507447#M136218</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-10-25T10:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: Group by Month and Year and Count by Name field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Month-and-Year-and-Count-by-Name-field/m-p/507449#M136220</link>
      <description>&lt;P&gt;Thanks for your help, if I want the results to look like the below what do I have to chance in your code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;month&amp;nbsp; &amp;nbsp;count&lt;BR /&gt;10-06&amp;nbsp;&amp;nbsp; 673&lt;BR /&gt;10-05&amp;nbsp;&amp;nbsp; 79&lt;BR /&gt;10-04&amp;nbsp;&amp;nbsp; 942&lt;BR /&gt;10-03&amp;nbsp;&amp;nbsp; 970&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 11:01:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Month-and-Year-and-Count-by-Name-field/m-p/507449#M136220</guid>
      <dc:creator>zdassu</dc:creator>
      <dc:date>2018-10-25T11:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: Group by Month and Year and Count by Name field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Month-and-Year-and-Count-by-Name-field/m-p/507451#M136221</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/59173"&gt;@zdassu&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for your help, if I want the results to look like the below what do I have to chance in your code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;month&amp;nbsp; &amp;nbsp;count&lt;BR /&gt;10-06&amp;nbsp;&amp;nbsp; 673&lt;BR /&gt;10-05&amp;nbsp;&amp;nbsp; 79&lt;BR /&gt;10-04&amp;nbsp;&amp;nbsp; 942&lt;BR /&gt;10-03&amp;nbsp;&amp;nbsp; 970&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since you don't want name in the output, how would you modify &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;'s SQL code?&lt;/P&gt;
&lt;P&gt;Note that this is so easy that you will be able to do it as an "exercise for the reader".&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 11:12:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Month-and-Year-and-Count-by-Name-field/m-p/507451#M136221</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-25T11:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Group by Month and Year and Count by Name field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Month-and-Year-and-Count-by-Name-field/m-p/507453#M136223</link>
      <description>&lt;P&gt;I changed the code and it works fine&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select put(Date,yymmd5.) as month, count(*) as count
from have
group by month
order by month desc; 
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Oct 2018 11:19:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Month-and-Year-and-Count-by-Name-field/m-p/507453#M136223</guid>
      <dc:creator>zdassu</dc:creator>
      <dc:date>2018-10-25T11:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: Group by Month and Year and Count by Name field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Month-and-Year-and-Count-by-Name-field/m-p/507458#M136225</link>
      <description>&lt;P&gt;You can know open the knot in your handkerchief that should remind you to learn something new in SAS today &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 11:48:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Month-and-Year-and-Count-by-Name-field/m-p/507458#M136225</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-25T11:48:05Z</dc:date>
    </item>
  </channel>
</rss>

