<?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: Counting obs by month with specific format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Counting-obs-by-month-with-specific-format/m-p/203388#M266949</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you everyone - this all helped!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jul 2015 16:26:51 GMT</pubDate>
    <dc:creator>myboys2</dc:creator>
    <dc:date>2015-07-15T16:26:51Z</dc:date>
    <item>
      <title>Counting obs by month with specific format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-obs-by-month-with-specific-format/m-p/203383#M266944</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi - I am trying to count the number of observations every month with date in format of 06/30/15 &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jul 2015 13:30:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-obs-by-month-with-specific-format/m-p/203383#M266944</guid>
      <dc:creator>myboys2</dc:creator>
      <dc:date>2015-07-15T13:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Counting obs by month with specific format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-obs-by-month-with-specific-format/m-p/203384#M266945</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi MyBoys2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could create a variable with the month, something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data &lt;SPAN style="font-size: 13.3333330154419px;"&gt;need&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; month=substrn(date,1,2);*If format is categorical;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; month=substrn(put(date,mmddyy8.),1,2);*If format is numerical;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;Doing this you will have a variable to group, and with a sql you could count it like&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;proc sql;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;select count (*) as number, month&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;from &lt;SPAN style="font-size: 13.3333330154419px;"&gt;need&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;group by month;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;quit;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jul 2015 13:55:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-obs-by-month-with-specific-format/m-p/203384#M266945</guid>
      <dc:creator>arodriguez</dc:creator>
      <dc:date>2015-07-15T13:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: Counting obs by month with specific format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-obs-by-month-with-specific-format/m-p/203385#M266946</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the date variable is numeric then&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have1;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;month = put(begin_date,monname3.);&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 13.3333330154419px;"&gt;* If you want the full month name use monname.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;year = year(begin_date);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the date variable is character then &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;data have1;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;set have;&lt;/P&gt;&lt;P&gt;month = put(input(begin_date,mmddyy10.),monname3.);&amp;nbsp; * If you want the full month name use monname.);&lt;/P&gt;&lt;P&gt;yr =year(input(begin_date,mmddyy10.));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Counting the number of obs for each month&lt;/STRONG&gt; :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Using Proc Sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table Want as &lt;/P&gt;&lt;P&gt;select Year,Month,count(*) as ObsCnt from have1&lt;/P&gt;&lt;P&gt;group by year,month;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Using Datastep;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;proc sort data = have1 out =have2;&lt;/P&gt;&lt;P&gt;by year month;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have2;&lt;/P&gt;&lt;P&gt;if first.year or first.month then ObsCnt=1;&lt;/P&gt;&lt;P&gt;else ObsCnt+1;&lt;/P&gt;&lt;P&gt;by year month;&lt;/P&gt;&lt;P&gt;if last.year or last.month then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jul 2015 14:28:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-obs-by-month-with-specific-format/m-p/203385#M266946</guid>
      <dc:creator>MadhuKorni</dc:creator>
      <dc:date>2015-07-15T14:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: Counting obs by month with specific format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-obs-by-month-with-specific-format/m-p/203386#M266947</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just to note, you don't actually need to create a month variable, you can just put that in the group by:&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333330154419px; font-family: inherit;"&gt;proc sql;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333330154419px; font-family: inherit;"&gt;select count (*) as number, month(&amp;lt;datevar&amp;gt;) as month&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333330154419px; font-family: inherit;"&gt;from &lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333330154419px; font-family: inherit;"&gt;need&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333330154419px; font-family: inherit;"&gt;group by month(&amp;lt;datavar&amp;gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333330154419px; font-family: inherit;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333330154419px; font-family: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333330154419px; font-family: inherit;"&gt;Where &amp;lt;datevar&amp;gt; should be replaced with the variable containing the date data.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jul 2015 14:45:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-obs-by-month-with-specific-format/m-p/203386#M266947</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-07-15T14:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: Counting obs by month with specific format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-obs-by-month-with-specific-format/m-p/203387#M266948</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use a format on your data with proc freq.&amp;nbsp; &lt;SPAN style="font-size: 13.3333330154419px;"&gt;If you want by year month use the format yymon7. instead.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc freq data=have noprint;&lt;/P&gt;&lt;P&gt;table date_var/out=want;&lt;/P&gt;&lt;P&gt;format date_var monname.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jul 2015 15:28:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-obs-by-month-with-specific-format/m-p/203387#M266948</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-07-15T15:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: Counting obs by month with specific format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-obs-by-month-with-specific-format/m-p/203388#M266949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you everyone - this all helped!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jul 2015 16:26:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-obs-by-month-with-specific-format/m-p/203388#M266949</guid>
      <dc:creator>myboys2</dc:creator>
      <dc:date>2015-07-15T16:26:51Z</dc:date>
    </item>
  </channel>
</rss>

