<?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 Pick the one which has latest in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Pick-the-one-which-has-latest/m-p/681572#M24039</link>
    <description>&lt;P&gt;&lt;BR /&gt;I have to create a code using the dateset which is already in my sas library .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if&amp;nbsp;&lt;/P&gt;&lt;P&gt;Count ( account_number) &amp;gt; 1 &amp;amp; Distinct (email_address) &amp;amp; Distinct ( Timestamp)&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then V_timestamp = max (Timestamp) ;&lt;/P&gt;&lt;P&gt;else&amp;nbsp;&lt;/P&gt;&lt;P&gt;V_timestamp = ' ' ;&lt;/P&gt;&lt;P&gt;/*condition says that if an account is coming more than 1 with distinct email ids and timestamp then it should pick an account that have latest timestamp and remove the rest */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please help me as in my SAS catalog there is no format mentioned for field timestamp so i see blank in content file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also shd we include email address format too?&lt;/P&gt;&lt;P&gt;can you pls help me built a logic on the above condition explained.&amp;nbsp;&lt;/P&gt;&lt;P&gt;HELP will be APPRECIATED &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;FYI :&amp;nbsp;I am a novice user.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Sep 2020 19:29:04 GMT</pubDate>
    <dc:creator>librasonali</dc:creator>
    <dc:date>2020-09-04T19:29:04Z</dc:date>
    <item>
      <title>Pick the one which has latest</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Pick-the-one-which-has-latest/m-p/681572#M24039</link>
      <description>&lt;P&gt;&lt;BR /&gt;I have to create a code using the dateset which is already in my sas library .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if&amp;nbsp;&lt;/P&gt;&lt;P&gt;Count ( account_number) &amp;gt; 1 &amp;amp; Distinct (email_address) &amp;amp; Distinct ( Timestamp)&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then V_timestamp = max (Timestamp) ;&lt;/P&gt;&lt;P&gt;else&amp;nbsp;&lt;/P&gt;&lt;P&gt;V_timestamp = ' ' ;&lt;/P&gt;&lt;P&gt;/*condition says that if an account is coming more than 1 with distinct email ids and timestamp then it should pick an account that have latest timestamp and remove the rest */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please help me as in my SAS catalog there is no format mentioned for field timestamp so i see blank in content file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also shd we include email address format too?&lt;/P&gt;&lt;P&gt;can you pls help me built a logic on the above condition explained.&amp;nbsp;&lt;/P&gt;&lt;P&gt;HELP will be APPRECIATED &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;FYI :&amp;nbsp;I am a novice user.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Sep 2020 19:29:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Pick-the-one-which-has-latest/m-p/681572#M24039</guid>
      <dc:creator>librasonali</dc:creator>
      <dc:date>2020-09-04T19:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: Pick the one which has latest timestamp</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Pick-the-one-which-has-latest/m-p/681579#M24040</link>
      <description>&lt;P&gt;You are asking for "&lt;SPAN&gt;&amp;nbsp;help me built a &lt;STRONG&gt;logic&lt;/STRONG&gt; on the above condition explained."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The logic should include next steps:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1) sort the input dataset by&amp;nbsp;&lt;STRONG&gt;account_number email_address timestamp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;2) Subset from the sorted dataset the wanted observations using a code like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set sorted;
  by  &lt;SPAN&gt;&lt;STRONG&gt;account_number email_address timestamp;&lt;/STRONG&gt;&lt;/SPAN&gt;
      if last.email_address;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Sep 2020 10:14:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Pick-the-one-which-has-latest/m-p/681579#M24040</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-09-04T10:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: Pick the one which has latest timestamp</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Pick-the-one-which-has-latest/m-p/681584#M24041</link>
      <description>&lt;P&gt;And a SQL version:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   create table want as
      select account_number, email_address, timestamp
         group by account_number, email_address
         having timestamp = max(timestamp)
   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Sep 2020 10:43:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Pick-the-one-which-has-latest/m-p/681584#M24041</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2020-09-04T10:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: Pick the one which has latest timestamp</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Pick-the-one-which-has-latest/m-p/681585#M24042</link>
      <description>thanks for the reply !&lt;BR /&gt;data want;&lt;BR /&gt;set sorted;&lt;BR /&gt;by account_number email_address timestamp;&lt;BR /&gt;if last.timestamp; /* i changed this as i want accounts with latest timestamps*/&lt;BR /&gt;run;&lt;BR /&gt;Also i want this logic when an account count is gr 1 i.e when A1 account is coming more than 1 times with distinct (email ids and timestamps) then i want last.timestamp .&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Sep 2020 10:51:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Pick-the-one-which-has-latest/m-p/681585#M24042</guid>
      <dc:creator>librasonali</dc:creator>
      <dc:date>2020-09-04T10:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: Pick the one which has latest timestamp</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Pick-the-one-which-has-latest/m-p/681588#M24043</link>
      <description>thank you for the reply !&lt;BR /&gt;i have already applied this approach&lt;BR /&gt;libname a SAS library&lt;BR /&gt;proc sql;&lt;BR /&gt;&lt;BR /&gt;select count(distinct(account_number) &amp;gt;1 , distinct(email_address), distinct(timestamp) from a.dataset&lt;BR /&gt;group by account_number, email_address&lt;BR /&gt;having timestamp = max(timestamp);&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;will this fine ? as i was using this approach was not getting expecting.. so was trying with SAS</description>
      <pubDate>Fri, 04 Sep 2020 11:00:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Pick-the-one-which-has-latest/m-p/681588#M24043</guid>
      <dc:creator>librasonali</dc:creator>
      <dc:date>2020-09-04T11:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: Pick the one which has latest timestamp</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Pick-the-one-which-has-latest/m-p/681589#M24044</link>
      <description>&lt;P&gt;You misunderstand what the LAST. variable does. By using last.timestamp, you will get &lt;EM&gt;every distinct timestamp&lt;/EM&gt; once in your output dataset, as you use timestamp as the lowest-level group variable here. Since you only want the &lt;EM&gt;last timestamp within an account&lt;/EM&gt;, you need to use last.account on a dataset sorted by account and timestamp.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My impression is that, for any account, you want to only keep the latest email address as the valid one.&lt;/P&gt;
&lt;P&gt;This can be done with SORT and DATA steps:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by account timetstamp;
run;

data want;
set have;
by account;
if last.account;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or, with SQL:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
  select distinct *
  from have
  group by account
  having timestamp = max(timestamp)
;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The DISTINCT can be omitted if there are no completely duplicate entries for any given account.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Sep 2020 11:03:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Pick-the-one-which-has-latest/m-p/681589#M24044</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-04T11:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: Pick the one which has latest timestamp</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Pick-the-one-which-has-latest/m-p/682143#M24080</link>
      <description>hey !&lt;BR /&gt;i donot want the last i want the latest, eg if an Account A1 have 2 email ids i.e s e1 have timestamp 12/22/2020 12:00:00 and e2 is 11/20/2020 10:00:00 then it should pick E1 email id that is the latest one ,</description>
      <pubDate>Tue, 08 Sep 2020 06:51:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Pick-the-one-which-has-latest/m-p/682143#M24080</guid>
      <dc:creator>librasonali</dc:creator>
      <dc:date>2020-09-08T06:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: Pick the one which has latest timestamp</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Pick-the-one-which-has-latest/m-p/682145#M24081</link>
      <description>&lt;P&gt;When you sort by account and timestamp, last.account indicates the latest for that account. last.timestamp indicates the last for that particular timestamp, which would only make sense if you want to filter out duplicate timestamp entries.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2020 07:02:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Pick-the-one-which-has-latest/m-p/682145#M24081</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-08T07:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: Pick the one which has latest timestamp</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Pick-the-one-which-has-latest/m-p/682164#M24087</link>
      <description>thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; !</description>
      <pubDate>Tue, 08 Sep 2020 08:14:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Pick-the-one-which-has-latest/m-p/682164#M24087</guid>
      <dc:creator>librasonali</dc:creator>
      <dc:date>2020-09-08T08:14:24Z</dc:date>
    </item>
    <item>
      <title>Re: Pick the one which has latest timestamp</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Pick-the-one-which-has-latest/m-p/682166#M24089</link>
      <description>&lt;P&gt;PS all my previous posts in this thread make the assumption that datetime values are stored as such, and not as strings; see your other thread.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2020 08:20:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Pick-the-one-which-has-latest/m-p/682166#M24089</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-08T08:20:19Z</dc:date>
    </item>
  </channel>
</rss>

