<?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: Grouping the data by month in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Grouping-the-data-by-month/m-p/536030#M147250</link>
    <description>&lt;P&gt;Your ADM_DT variable actually contains datetimes, not dates.&amp;nbsp; It's easier if you convert those to dates:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;just_the_date = datepart(ADM_DT);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can get the counts directly by applying a format:&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 just_the_date;&lt;/P&gt;
&lt;P&gt;format just_the_date mmyyd.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to use just the dates in a particular year, you can add a subsetting statement before the final RUN statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where year(just_the_date) = 2018;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Feb 2019 20:22:22 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2019-02-15T20:22:22Z</dc:date>
    <item>
      <title>Grouping the data by month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-the-data-by-month/m-p/536021#M147245</link>
      <description>&lt;DIV class="branch"&gt;&lt;DIV align="center"&gt;How would i write an if condition to group cases by the admission date for the 12 months in a year&amp;nbsp;&lt;/DIV&gt;&lt;DIV align="center"&gt;&lt;BR /&gt;&lt;P&gt;ADM_DT field is in Numeric DATETIME20 format&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV align="center"&gt;i.e. I want to count the no of cases where ADM_DT would fall e.g. between 01 Jan and 31 Jan 2018&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 15 Feb 2019 20:05:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-the-data-by-month/m-p/536021#M147245</guid>
      <dc:creator>Ranjeeta</dc:creator>
      <dc:date>2019-02-15T20:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping the data by month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-the-data-by-month/m-p/536025#M147246</link>
      <description>&lt;P&gt;1. Please provide us a comprehensive sample of data HAVE&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp;Please provide us a comprehensive sample of data WANT&lt;/P&gt;
&lt;P&gt;3. Explain briefly what you want to accomplish&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS family would provide you the solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 20:09:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-the-data-by-month/m-p/536025#M147246</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-15T20:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping the data by month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-the-data-by-month/m-p/536027#M147247</link>
      <description>&lt;P&gt;Data I Have&lt;/P&gt;&lt;P&gt;KEY 5482 5253 6942&lt;/P&gt;&lt;P&gt;ADM_DT&amp;nbsp; 29JUN2018:00:00:00&amp;nbsp; 09JUN2018:00:00:00&amp;nbsp; 15JUL2018:00:00:00&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA WANT&lt;/P&gt;&lt;P&gt;JUN2018 2 Keys&lt;/P&gt;&lt;P&gt;JULY2018 1KEY&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically I want to count the no of cases that are there in each month in the above e.g 2 keys were between the dates of 01 June 2018 to 30 June 2018&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 20:16:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-the-data-by-month/m-p/536027#M147247</guid>
      <dc:creator>Ranjeeta</dc:creator>
      <dc:date>2019-02-15T20:16:19Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping the data by month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-the-data-by-month/m-p/536030#M147250</link>
      <description>&lt;P&gt;Your ADM_DT variable actually contains datetimes, not dates.&amp;nbsp; It's easier if you convert those to dates:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;just_the_date = datepart(ADM_DT);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can get the counts directly by applying a format:&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 just_the_date;&lt;/P&gt;
&lt;P&gt;format just_the_date mmyyd.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to use just the dates in a particular year, you can add a subsetting statement before the final RUN statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where year(just_the_date) = 2018;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 20:22:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-the-data-by-month/m-p/536030#M147250</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-02-15T20:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping the data by month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-the-data-by-month/m-p/536031#M147251</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240770"&gt;@Ranjeeta&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Data I Have&lt;/P&gt;
&lt;P&gt;KEY 5482 5253 6942&lt;/P&gt;
&lt;P&gt;ADM_DT&amp;nbsp; 29JUN2018:00:00:00&amp;nbsp; 09JUN2018:00:00:00&amp;nbsp; 15JUL2018:00:00:00&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA WANT&lt;/P&gt;
&lt;P&gt;JUN2018 2 Keys&lt;/P&gt;
&lt;P&gt;JULY2018 1KEY&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically I want to count the no of cases that are there in each month in the above e.g 2 keys were between the dates of 01 June 2018 to 30 June 2018&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;1) those values are DATETIME not dates.&lt;/P&gt;
&lt;P&gt;2) is that the way you SAS data set actually looks?&lt;/P&gt;
&lt;P&gt;I would expect something that looks more like:&lt;/P&gt;
&lt;P&gt;Key&amp;nbsp;&amp;nbsp;&amp;nbsp; ADM_DT&lt;/P&gt;
&lt;P&gt;5482&amp;nbsp; 29JUN2018:00:00:00&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;5253&amp;nbsp; 09JUN2018:00:00:00&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;6942 15JUL2018:00:00:00&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want a report (people read) or a data set(for further processing).&lt;/P&gt;
&lt;P&gt;One possible example report:&lt;/P&gt;
&lt;PRE&gt;proc freq data=have ;
   where not missing(key);
   tables adm_dt;
   format adm_dt dtmonyy7.;
run;&lt;/PRE&gt;
&lt;P&gt;the frequency count would be the number of keys.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 20:25:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-the-data-by-month/m-p/536031#M147251</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-02-15T20:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping the data by month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-the-data-by-month/m-p/536034#M147252</link>
      <description>&lt;P&gt;Yes the data looks the way you have described&lt;/P&gt;&lt;P&gt;I want a report that people read&lt;/P&gt;&lt;P&gt;How would I sort by month ?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 20:34:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-the-data-by-month/m-p/536034#M147252</guid>
      <dc:creator>Ranjeeta</dc:creator>
      <dc:date>2019-02-15T20:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping the data by month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-the-data-by-month/m-p/536040#M147256</link>
      <description>&lt;P&gt;Apply formats to your date variable.&lt;/P&gt;
&lt;P&gt;You need to find the format you want, for example DTYEAR may be valid (not sure).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an example of how that can work:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://gist.github.com/statgeek/0cae5568752959b035516d6ac07a20fb" target="_blank"&gt;https://gist.github.com/statgeek/0cae5568752959b035516d6ac07a20fb&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/240770"&gt;@Ranjeeta&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Yes the data looks the way you have described&lt;/P&gt;
&lt;P&gt;I want a report that people read&lt;/P&gt;
&lt;P&gt;How would I sort by month ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 20:38:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-the-data-by-month/m-p/536040#M147256</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-15T20:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping the data by month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-the-data-by-month/m-p/536053#M147264</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240770"&gt;@Ranjeeta&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Yes the data looks the way you have described&lt;/P&gt;
&lt;P&gt;I want a report that people read&lt;/P&gt;
&lt;P&gt;How would I sort by month ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The proc freq suggested code will sort the output by increasing date by default. That is how proc freq generally works with numeric values such which includes SAS date, datetime and time values. The format will group the counts by month and year.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 20:54:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-the-data-by-month/m-p/536053#M147264</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-02-15T20:54:15Z</dc:date>
    </item>
  </channel>
</rss>

