<?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: Proc Sql - group by formatted date value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-group-by-formatted-date-value/m-p/749928#M235780</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/39634"&gt;@Julie4435637&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see that you need "&lt;SPAN&gt;&lt;STRONG&gt;I just want a record count by month&lt;/STRONG&gt;." . With this requirement, typically, one would expect&amp;nbsp; one row for each month.(As a corollary for the same months in different years, one would expect one row for each year and month combination).&lt;BR /&gt;In the output&amp;nbsp; you have posted there are multiple records for the same month 07/2020.&lt;BR /&gt;Wondering if the output&amp;nbsp; you have posted is what you want OR one row for each month (and year) ?&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Jun 2021 17:36:39 GMT</pubDate>
    <dc:creator>Sajid01</dc:creator>
    <dc:date>2021-06-23T17:36:39Z</dc:date>
    <item>
      <title>Proc Sql - group by formatted date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-group-by-formatted-date-value/m-p/749757#M235682</link>
      <description>&lt;P&gt;I am sure there is a easy way to do this but I am having a mental block now.&amp;nbsp; Here is my code:&lt;/P&gt;
&lt;PRE&gt;proc sql feedback;&lt;BR /&gt;	select dt format=mmyys10., count(*) as cnt&lt;BR /&gt;	from tst&lt;BR /&gt;	group by dt;&lt;BR /&gt;quit;&lt;/PRE&gt;
&lt;P&gt;Here is a sample of output.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Julie4435637_0-1624405174970.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60639iB9C541B3DA5D2BDF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Julie4435637_0-1624405174970.png" alt="Julie4435637_0-1624405174970.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I just want a record count by month.&amp;nbsp; I want it to be done in proc sql.&amp;nbsp; I don't want to use freq or other procedures.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 23:41:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-group-by-formatted-date-value/m-p/749757#M235682</guid>
      <dc:creator>Julie4435637</dc:creator>
      <dc:date>2021-06-22T23:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql - group by formatted date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-group-by-formatted-date-value/m-p/749760#M235684</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql feedback;
	select put(dt,mmyys10.)  as dt_, 
			count(*) as cnt
	from tst
	group by  dt_;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Jun 2021 00:12:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-group-by-formatted-date-value/m-p/749760#M235684</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2021-06-23T00:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql - group by formatted date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-group-by-formatted-date-value/m-p/749761#M235685</link>
      <description>&lt;P&gt;SQL doesn’t respect formats for aggregation so you need to actually convert it to a character. SAS summary PROCs don’t have that limitation.&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/223452"&gt;@r_behata&lt;/a&gt;&amp;nbsp;solution illustrates how to do the conversion.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/39634"&gt;@Julie4435637&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am sure there is a easy way to do this but I am having a mental block now.&amp;nbsp; Here is my code:&lt;/P&gt;
&lt;PRE&gt;proc sql feedback;&lt;BR /&gt;	select dt format=mmyys10., count(*) as cnt&lt;BR /&gt;	from tst&lt;BR /&gt;	group by dt;&lt;BR /&gt;quit;&lt;/PRE&gt;
&lt;P&gt;Here is a sample of output.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Julie4435637_0-1624405174970.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60639iB9C541B3DA5D2BDF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Julie4435637_0-1624405174970.png" alt="Julie4435637_0-1624405174970.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I just want a record count by month.&amp;nbsp; I want it to be done in proc sql.&amp;nbsp; I don't want to use freq or other procedures.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 00:37:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-group-by-formatted-date-value/m-p/749761#M235685</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-06-23T00:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql - group by formatted date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-group-by-formatted-date-value/m-p/749786#M235701</link>
      <description>&lt;P&gt;If you don't have to use proc sql, i would switch to proc summary:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data= tst nway;
  class dt;
  format dt mmyys10.;
  output out= want(drop= _type_ rename= (_freq_ = cnt));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Jun 2021 05:57:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-group-by-formatted-date-value/m-p/749786#M235701</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-06-23T05:57:25Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql - group by formatted date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-group-by-formatted-date-value/m-p/749838#M235727</link>
      <description>proc sql;&lt;BR /&gt;create table want as&lt;BR /&gt;select intnx('month',date,0) as date format=mmyys10.,count(*) as cnt&lt;BR /&gt; from sashelp.stocks&lt;BR /&gt;  group by 1;&lt;BR /&gt;quit;</description>
      <pubDate>Wed, 23 Jun 2021 12:13:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-group-by-formatted-date-value/m-p/749838#M235727</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-06-23T12:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql - group by formatted date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-group-by-formatted-date-value/m-p/749928#M235780</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/39634"&gt;@Julie4435637&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see that you need "&lt;SPAN&gt;&lt;STRONG&gt;I just want a record count by month&lt;/STRONG&gt;." . With this requirement, typically, one would expect&amp;nbsp; one row for each month.(As a corollary for the same months in different years, one would expect one row for each year and month combination).&lt;BR /&gt;In the output&amp;nbsp; you have posted there are multiple records for the same month 07/2020.&lt;BR /&gt;Wondering if the output&amp;nbsp; you have posted is what you want OR one row for each month (and year) ?&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 17:36:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-group-by-formatted-date-value/m-p/749928#M235780</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2021-06-23T17:36:39Z</dc:date>
    </item>
  </channel>
</rss>

