<?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: Duplicate Rows When Group By Date in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-When-Group-By-Date/m-p/446368#M28872</link>
    <description>&lt;P&gt;You could try something like the following, replacing datevar with your own data variable&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;group by put(datepart(datevar), yymms.)&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 16 Mar 2018 22:44:32 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-03-16T22:44:32Z</dc:date>
    <item>
      <title>Duplicate Rows When Group By Date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-When-Group-By-Date/m-p/446362#M28869</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know why I am still getting multiple rows per date when I am grouping by the date?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; 
create table t1 as
select 
distinct datepart(campaign_send_datetime) as send_date format = MMYYS.,
count(distinct email_campaign_id) as b
from dmprod.vw_email_campaign_history
group by 1
order by 1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Mar 2018 22:12:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-When-Group-By-Date/m-p/446362#M28869</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2018-03-16T22:12:56Z</dc:date>
    </item>
    <item>
      <title>Average number of records by month</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-When-Group-By-Date/m-p/446325#M28879</link>
      <description>&lt;P&gt;Need some help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to find out by month the average amount of communications a person is getting in a two year period? Any thoughts?&lt;/P&gt;&lt;P&gt;Thanks ahead of time!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; 
create table t1 as
select 
distinct datepart(campaign_send_datetime) as send_date format = MMYYS.,
count(id_number)/count(history_id) as average
from dm.vw_email_campaign_history
where datepart(campaign_send_datetime) between '01MAR2016'd and '01MAR2018'd
group by 1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 20:23:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-When-Group-By-Date/m-p/446325#M28879</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2018-03-16T20:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate Rows When Group By Date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-When-Group-By-Date/m-p/446364#M28870</link>
      <description>&lt;P&gt;Here's the opuput:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 553px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/19248iC00CBBDCDEC8D731/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 22:15:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-When-Group-By-Date/m-p/446364#M28870</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2018-03-16T22:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate Rows When Group By Date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-When-Group-By-Date/m-p/446367#M28871</link>
      <description>&lt;P&gt;SQL doesn't group by formatted values, so it see's each date as a unique date.&lt;/P&gt;
&lt;P&gt;So if you want monthly data you need to create a month variable to group by or use a SAS PROC.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 22:43:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-When-Group-By-Date/m-p/446367#M28871</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-16T22:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate Rows When Group By Date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-When-Group-By-Date/m-p/446368#M28872</link>
      <description>&lt;P&gt;You could try something like the following, replacing datevar with your own data variable&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;group by put(datepart(datevar), yymms.)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Mar 2018 22:44:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-When-Group-By-Date/m-p/446368#M28872</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-16T22:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate Rows When Group By Date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-When-Group-By-Date/m-p/446383#M28874</link>
      <description>&lt;P&gt;Thanks Reeza, this was helpful!&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 23:29:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-When-Group-By-Date/m-p/446383#M28874</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2018-03-16T23:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: Average number of records by month</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-When-Group-By-Date/m-p/446400#M28880</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/174883"&gt;@Dogo23&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Need some help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to find out by month the average amount of communications a person is getting in a two year period? Any thoughts?&lt;/P&gt;
&lt;P&gt;Thanks ahead of time!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; 
create table t1 as
select 
distinct datepart(campaign_send_datetime) as send_date format = MMYYS.,
count(id_number)/count(history_id) as average
from dm.vw_email_campaign_history
where datepart(campaign_send_datetime) between '01MAR2016'd and '01MAR2018'd
group by 1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Post sample data in the form of a SAS data step creating such data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One of the things&amp;nbsp;which certainly needs change is&amp;nbsp;your group by statement. It should be something like:&lt;/P&gt;
&lt;PRE&gt;group by person_id, intnx('dtmonth',campaign_send_datetime,0,'b')&lt;/PRE&gt;</description>
      <pubDate>Sat, 17 Mar 2018 01:14:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-When-Group-By-Date/m-p/446400#M28880</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-03-17T01:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate Rows When Group By Date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-When-Group-By-Date/m-p/446408#M28881</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/174883"&gt;@Dogo23&lt;/a&gt;&amp;nbsp;I merged these two threads since they seem identical. Please don't post the same question multiple times.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Mar 2018 01:51:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-When-Group-By-Date/m-p/446408#M28881</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-17T01:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate Rows When Group By Date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-When-Group-By-Date/m-p/447267#M28925</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;The problems were related but I was looking for a unique answer to the group by problem with multiple datettime records.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 21:03:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-Rows-When-Group-By-Date/m-p/447267#M28925</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2018-03-20T21:03:09Z</dc:date>
    </item>
  </channel>
</rss>

