<?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 How to select mind date per each unique ID in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-select-mind-date-per-each-unique-ID/m-p/422036#M27175</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to take the earlier occurrence of each unique ID from a table I created. As of right now, if I say min (date), I am the earliest single record coming from that table and it is applied to each row in the new table. Instead, I wanted the earliest date attributed to each of those distinct ID's.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table t2 as&lt;BR /&gt;select&lt;BR /&gt;distinct campaign_id,&lt;BR /&gt;&lt;STRONG&gt;min (datepart(date)) as processed_dttm format= mmddyy8.,&lt;/STRONG&gt;&lt;BR /&gt;total_sent,&lt;BR /&gt;open,&lt;BR /&gt;click,&lt;BR /&gt;from t2;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Doing this, even though I asked for "distinct" ID, still applies the earliest single date (11/06/16) to every record in the new table.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Dec 2017 16:21:53 GMT</pubDate>
    <dc:creator>Dogo23</dc:creator>
    <dc:date>2017-12-18T16:21:53Z</dc:date>
    <item>
      <title>How to select mind date per each unique ID</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-select-mind-date-per-each-unique-ID/m-p/422036#M27175</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to take the earlier occurrence of each unique ID from a table I created. As of right now, if I say min (date), I am the earliest single record coming from that table and it is applied to each row in the new table. Instead, I wanted the earliest date attributed to each of those distinct ID's.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table t2 as&lt;BR /&gt;select&lt;BR /&gt;distinct campaign_id,&lt;BR /&gt;&lt;STRONG&gt;min (datepart(date)) as processed_dttm format= mmddyy8.,&lt;/STRONG&gt;&lt;BR /&gt;total_sent,&lt;BR /&gt;open,&lt;BR /&gt;click,&lt;BR /&gt;from t2;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Doing this, even though I asked for "distinct" ID, still applies the earliest single date (11/06/16) to every record in the new table.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2017 16:21:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-select-mind-date-per-each-unique-ID/m-p/422036#M27175</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2017-12-18T16:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to select mind date per each unique ID</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-select-mind-date-per-each-unique-ID/m-p/422038#M27176</link>
      <description>&lt;P&gt;Add a GROUP BY so the analysis is done by the GROUP variables. DISTINCT isn't what you're looking for in this case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table t2 as
select campaign_id,
min (datepart(date)) as processed_dttm format= mmddyy8.,
total_sent,
open,
click,
from t2
gorup by campaign_id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Dec 2017 16:27:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-select-mind-date-per-each-unique-ID/m-p/422038#M27176</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-18T16:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to select mind date per each unique ID</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-select-mind-date-per-each-unique-ID/m-p/422039#M27177</link>
      <description>&lt;P&gt;Note that you haven't applied aggregate functions to the remaining variables so you're still going to end up with your full table but a new variable that identifies the min date. This isn't the same behaviour you'd experience in a DBMS version of SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@schlotty23 wrote:&lt;BR /&gt;
&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to take the earlier occurrence of each unique ID from a table I created. As of right now, if I say min (date), I am the earliest single record coming from that table and it is applied to each row in the new table. Instead, I wanted the earliest date attributed to each of those distinct ID's.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table t2 as&lt;BR /&gt;select&lt;BR /&gt;distinct campaign_id,&lt;BR /&gt;&lt;STRONG&gt;min (datepart(date)) as processed_dttm format= mmddyy8.,&lt;/STRONG&gt;&lt;BR /&gt;total_sent,&lt;BR /&gt;open,&lt;BR /&gt;click,&lt;BR /&gt;from t2;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Doing this, even though I asked for "distinct" ID, still applies the earliest single date (11/06/16) to every record in the new table.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2017 16:28:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-select-mind-date-per-each-unique-ID/m-p/422039#M27177</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-18T16:28:14Z</dc:date>
    </item>
  </channel>
</rss>

