<?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: How to remove seconds from datetime (not round function) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-seconds-from-datetime-not-round-function/m-p/480851#M124298</link>
    <description>&lt;P&gt;Perhaps you just want to use the MOD() function to remove the seconds?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
 dt1='11JUN2018:17:48:29'dt;
 dt2='11JUN2018:17:48:30'dt;
 rdt1 = dt1 - mod(dt1,60);
 rdt2 = dt2 - mod(dt2,60);
 test1= dt1=dt2;
 test2= rdt1=rdt2 ;
 format dt: rdt: datetime20. ;
 put (_all_) (=/);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or better still test that the difference is less than a minute?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
  select * 
  from ds1 A, ds2 B
  where abs(A.datetime - B.datetime) &amp;lt;= 60 
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 24 Jul 2018 16:53:07 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-07-24T16:53:07Z</dc:date>
    <item>
      <title>How to remove seconds from datetime (not round function)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-seconds-from-datetime-not-round-function/m-p/480824#M124290</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a datetime variable&amp;nbsp;in two files that I&amp;nbsp;need to&amp;nbsp;merge, issue is&amp;nbsp;datetime variable in both files are different in seconds for few observations. For example in one file datetime is 06/11/2018 17:48:29 and in other file it is 17:48:30&lt;/P&gt;&lt;P&gt;I just want to&amp;nbsp;remove seconds from datetime so I can merge both files. how can I do that?&lt;/P&gt;&lt;P&gt;I&amp;nbsp;cannot round it because it is not working out.&lt;/P&gt;&lt;P&gt;Let me know, thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 15:06:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-seconds-from-datetime-not-round-function/m-p/480824#M124290</guid>
      <dc:creator>AMFR</dc:creator>
      <dc:date>2018-07-24T15:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove seconds from datetime (not round function)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-seconds-from-datetime-not-round-function/m-p/480827#M124292</link>
      <description>&lt;PRE&gt;proc sql;
  create table want as
  select...
  from   havea a
  left join haveb b
  on     date(a.dtvar)=date(b.dtvar)
  and    time(a.dtvar)=time(b.dtvar);
quit;&lt;/PRE&gt;
&lt;P&gt;You can use the time and date parts, might need to put time into time5 format or something.&amp;nbsp; You could also put both datetimes into text e8601dt replace the seconds part and read back in as datetime.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 15:15:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-seconds-from-datetime-not-round-function/m-p/480827#M124292</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-07-24T15:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove seconds from datetime (not round function)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-seconds-from-datetime-not-round-function/m-p/480836#M124297</link>
      <description>&lt;P&gt;You could create your own variable for matching purposes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;matchvar = int(datetimevar/60);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The merge (or join if using SQL) on matchvar.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't print matchvar.&amp;nbsp; It's neither a date nor a datetime.&amp;nbsp; It's the number of minutes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In practice, you may need to experiment with using ROUND instead of INT.&amp;nbsp; It's possible you need to match based on the closest minute rather than removing the seconds.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 15:35:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-seconds-from-datetime-not-round-function/m-p/480836#M124297</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-07-24T15:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove seconds from datetime (not round function)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-seconds-from-datetime-not-round-function/m-p/480851#M124298</link>
      <description>&lt;P&gt;Perhaps you just want to use the MOD() function to remove the seconds?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
 dt1='11JUN2018:17:48:29'dt;
 dt2='11JUN2018:17:48:30'dt;
 rdt1 = dt1 - mod(dt1,60);
 rdt2 = dt2 - mod(dt2,60);
 test1= dt1=dt2;
 test2= rdt1=rdt2 ;
 format dt: rdt: datetime20. ;
 put (_all_) (=/);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or better still test that the difference is less than a minute?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
  select * 
  from ds1 A, ds2 B
  where abs(A.datetime - B.datetime) &amp;lt;= 60 
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 16:53:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-seconds-from-datetime-not-round-function/m-p/480851#M124298</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-07-24T16:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove seconds from datetime (not round function)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-seconds-from-datetime-not-round-function/m-p/480862#M124299</link>
      <description>&lt;P&gt;Thank you very much. I found MOD function to remove seconds very helpful.&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 17:30:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-seconds-from-datetime-not-round-function/m-p/480862#M124299</guid>
      <dc:creator>AMFR</dc:creator>
      <dc:date>2018-07-24T17:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove seconds from datetime (not round function)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-seconds-from-datetime-not-round-function/m-p/480863#M124300</link>
      <description>&lt;P&gt;Thank you!!&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 17:30:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-seconds-from-datetime-not-round-function/m-p/480863#M124300</guid>
      <dc:creator>AMFR</dc:creator>
      <dc:date>2018-07-24T17:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove seconds from datetime (not round function)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-seconds-from-datetime-not-round-function/m-p/480864#M124301</link>
      <description>&lt;P&gt;Many thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 17:31:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-seconds-from-datetime-not-round-function/m-p/480864#M124301</guid>
      <dc:creator>AMFR</dc:creator>
      <dc:date>2018-07-24T17:31:34Z</dc:date>
    </item>
  </channel>
</rss>

