<?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: Find record with joining time greater than relieving time in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-record-with-joining-time-greater-than-relieving-time/m-p/862026#M340480</link>
    <description>&lt;P&gt;Storing dates or times as character is idiocy squared. It takes a&amp;nbsp;&lt;STRONG&gt;LOT&lt;/STRONG&gt; more space and deprives you of the use of all the tools SAS provides for such data.&lt;/P&gt;
&lt;P&gt;If you can't go back to the original import process, fix the data first like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data emp_fixed;
set emp (rename=(join=_join relieve=_relieve));
join = input(_join,e8601ft19.);
relieve = input(_relieve,e8601dt19.);
format join relieve e8601dt19.;
drop _join _relieve;
run;

data emp1;
set emp_fixed;
where join gt relieve;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 02 Mar 2023 20:06:57 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-03-02T20:06:57Z</dc:date>
    <item>
      <title>Find record with joining time greater than relieving time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-record-with-joining-time-greater-than-relieving-time/m-p/861993#M340460</link>
      <description>&lt;P&gt;Hi All,&lt;BR /&gt;In my dataset, I want to retrieve only those records where emp joining time (hh:mm) &amp;gt; relieve time (hh:mm)&lt;/P&gt;
&lt;P&gt;e.g I am not sure how to import dates into emp dataset. Please check.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data emp;
input id join relieve;
cards;
101 2022-11-24T09:21:04 2022-11-24T11:24:14
102 2022-12-09T07:19:10 2022-12-09T05:19:10
;
run;

data emp1;
set emp;
join1= substr(join,12,5);
jointime = timepart( intnx('dthour',input(join1,time5.),0,'same'));
relieve1= substr(relieve,12,5);
relievetime = timepart( intnx('dthour',input(relieve1,time5.),0,'same'));
format jointime relievetime time5.;
run;

data final;
set emp1;
where jointime&amp;gt;relievetime;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Mar 2023 18:15:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-record-with-joining-time-greater-than-relieving-time/m-p/861993#M340460</guid>
      <dc:creator>abraham1</dc:creator>
      <dc:date>2023-03-02T18:15:17Z</dc:date>
    </item>
    <item>
      <title>Re: Find record with joining time greater than relieving time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-record-with-joining-time-greater-than-relieving-time/m-p/861995#M340461</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/357256"&gt;@abraham1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi All,&lt;BR /&gt;In my dataset, I want to retrieve only those records where emp joining time (hh:mm) &amp;gt; relieve time (hh:mm)&lt;/P&gt;
&lt;P&gt;e.g I am not sure how to import dates into emp dataset. Please check.&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Comment: never work with dates and times as character strings. To do arithmetic or logical operations on dates and times (which you want to do, comparing join to relieve), always use numeric date, date/time or time values. To obtain numeric dates and times, you import the data using the proper INFORMAT when reading the data (in this case the informat is e8601dt.), which converts the date/times like 2022-11-24T09:21:04 into actual SAS numeric values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data emp;
input id join :e8601dt. relieve :e8601dt.;
format join relieve e8601dt.;
cards;
101 2022-11-24T09:21:04 2022-11-24T11:24:14
102 2022-12-09T07:19:10 2022-12-09T05:19:10
;

data want;
    set emp;
    if timepart(join)&amp;gt;timepart(relieve);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 18:36:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-record-with-joining-time-greater-than-relieving-time/m-p/861995#M340461</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-03-02T18:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: Find record with joining time greater than relieving time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-record-with-joining-time-greater-than-relieving-time/m-p/862004#M340468</link>
      <description>&lt;P&gt;Thank you sir for the details.&lt;/P&gt;
&lt;P&gt;When the dates are stored in character format in dataset, how can this be handled.&lt;/P&gt;
&lt;P&gt;I used below code but don't know how to pull data&amp;nbsp;with joining time greater than relieving time. can you please help me one more time.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data emp;
input id join $20. relieve $20.;
cards;
101 2022-11-24T09:21:04 2022-11-24T11:24:14
102 2022-12-09T07:19:10 2022-12-09T05:19:10
;
run;

data emp1;
set emp;
join1= substr(join,12,5);
jointime = timepart( intnx('dthour',input(join1,time5.),0,'same'));
relieve1= substr(relieve,12,5);
relievetime = timepart( intnx('dthour',input(relieve1,time5.),0,'same'));
format jointime relievetime time5.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Mar 2023 19:18:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-record-with-joining-time-greater-than-relieving-time/m-p/862004#M340468</guid>
      <dc:creator>abraham1</dc:creator>
      <dc:date>2023-03-02T19:18:08Z</dc:date>
    </item>
    <item>
      <title>Re: Find record with joining time greater than relieving time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-record-with-joining-time-greater-than-relieving-time/m-p/862026#M340480</link>
      <description>&lt;P&gt;Storing dates or times as character is idiocy squared. It takes a&amp;nbsp;&lt;STRONG&gt;LOT&lt;/STRONG&gt; more space and deprives you of the use of all the tools SAS provides for such data.&lt;/P&gt;
&lt;P&gt;If you can't go back to the original import process, fix the data first like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data emp_fixed;
set emp (rename=(join=_join relieve=_relieve));
join = input(_join,e8601ft19.);
relieve = input(_relieve,e8601dt19.);
format join relieve e8601dt19.;
drop _join _relieve;
run;

data emp1;
set emp_fixed;
where join gt relieve;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Mar 2023 20:06:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-record-with-joining-time-greater-than-relieving-time/m-p/862026#M340480</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-03-02T20:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: Find record with joining time greater than relieving time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-record-with-joining-time-greater-than-relieving-time/m-p/862058#M340496</link>
      <description>&lt;P&gt;I am not getting expected result as I need to compare time in HH:MM between two dates. I have added one more record (103) where time&amp;nbsp;&lt;CODE class=" language-sas"&gt;08:19 &amp;gt;05:11&amp;nbsp;&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;irrepective of &lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;date.&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;I&amp;nbsp;am&amp;nbsp;expecting&amp;nbsp;this&amp;nbsp;record also&amp;nbsp;to&amp;nbsp;be&amp;nbsp;&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;retrieved&amp;nbsp;along&amp;nbsp;with&amp;nbsp;101.&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data emp;
input id join $20. relieve $20.;
cards;
101 2022-11-24T09:21:04 2022-11-24T11:24:14
102 2022-12-09T07:19:10 2022-12-09T05:19:10
103 2022-12-05T08:19:10 2022-12-09T05:11:10
;
run;
data emp_fixed;
set emp (rename=(join=_join relieve=_relieve));
join = input(_join,e8601dt19.);
relieve = input(_relieve,e8601dt19.);
format join relieve e8601dt19.;
drop _join _relieve;
run;
data emp1;
set emp_fixed;
where join gt relieve;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Mar 2023 01:37:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-record-with-joining-time-greater-than-relieving-time/m-p/862058#M340496</guid>
      <dc:creator>abraham1</dc:creator>
      <dc:date>2023-03-03T01:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: Find record with joining time greater than relieving time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-record-with-joining-time-greater-than-relieving-time/m-p/862060#M340498</link>
      <description>I have already provided code that works.</description>
      <pubDate>Fri, 03 Mar 2023 02:08:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-record-with-joining-time-greater-than-relieving-time/m-p/862060#M340498</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-03-03T02:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: Find record with joining time greater than relieving time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-record-with-joining-time-greater-than-relieving-time/m-p/862061#M340499</link>
      <description>Thank you sir as both of you can help me to resolve my query.</description>
      <pubDate>Fri, 03 Mar 2023 02:21:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-record-with-joining-time-greater-than-relieving-time/m-p/862061#M340499</guid>
      <dc:creator>abraham1</dc:creator>
      <dc:date>2023-03-03T02:21:29Z</dc:date>
    </item>
  </channel>
</rss>

