<?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: Need to change DB2 timestamp to numeric SAS timestamp in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Need-to-change-DB2-timestamp-to-numeric-SAS-timestamp/m-p/892898#M39720</link>
    <description>&lt;P&gt;You will need to convert this source string to a pattern for which there is a SAS infomat. Let me know if below conversion is working for you.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data demo;
  input have_string $25.;
  have_string=prxchange('s/^(\d+-\d+-\d+).(\d+).(\d+).(\d+.*)$/$1T$2:$3:$4/oi',1,strip(have_string));
  have_dttm=input(strip(have_string),e8601dt26.6);

  /*Get the current timestamp*/;
  Current_time = DATETIME();

  /* subtract 14 hours (50400 seconds) */
  _14_hours_ago = intnx('dthour',current_time,-14,'s');
  datalines;
2023-09-05-06.15.16.130035
2023-09-05T06:15:16.130035
;

proc print data=demo;
  format have_dttm Current_time _14_hours_ago datetime25.6;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 06 Sep 2023 11:07:24 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2023-09-06T11:07:24Z</dc:date>
    <item>
      <title>Need to change DB2 timestamp to numeric SAS timestamp</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-to-change-DB2-timestamp-to-numeric-SAS-timestamp/m-p/892887#M39718</link>
      <description>In input file have data like this -&lt;BR /&gt;2023-09-05-06.15.16.130035&lt;BR /&gt;I want to check if this timestamp is less than current timestamp - 14 hours&lt;BR /&gt;I am able to get the 14 hours back numeric current timestamp with this code&lt;BR /&gt;Data_null_;&lt;BR /&gt;File statrep;&lt;BR /&gt;/*Get the current timestamp*/;&lt;BR /&gt;Current_time = DATETIME();&lt;BR /&gt;/* subtract 14 hours (50400 seconds) */&lt;BR /&gt;14_hours_ago = current_time -50400;&lt;BR /&gt;I need my input file timestamp to change to numeric format so that I can compare these two dates if it's less or greter for my further process.&lt;BR /&gt;Or if there any other way to compare dates please let me know</description>
      <pubDate>Wed, 06 Sep 2023 10:19:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-to-change-DB2-timestamp-to-numeric-SAS-timestamp/m-p/892887#M39718</guid>
      <dc:creator>SBKH</dc:creator>
      <dc:date>2023-09-06T10:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: Need to change DB2 timestamp to numeric SAS timestamp</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-to-change-DB2-timestamp-to-numeric-SAS-timestamp/m-p/892894#M39719</link>
      <description>&lt;P&gt;So it's DB2 but you are reading it from a file?&lt;/P&gt;
&lt;P&gt;If you access DB2 directly the SAS/ACCESS libname engine maps DB2 timestamps to SAS datetime auotmatically.&lt;/P&gt;
&lt;P&gt;if you can't find any suitable existing informat, you can create your own:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p0n990vq8gxca6n1vnsracr6jp2c.htm" target="_blank"&gt;SAS Help Center: Syntax: PROC FORMAT PICTURE Statement&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2023 10:37:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-to-change-DB2-timestamp-to-numeric-SAS-timestamp/m-p/892894#M39719</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2023-09-06T10:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: Need to change DB2 timestamp to numeric SAS timestamp</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-to-change-DB2-timestamp-to-numeric-SAS-timestamp/m-p/892898#M39720</link>
      <description>&lt;P&gt;You will need to convert this source string to a pattern for which there is a SAS infomat. Let me know if below conversion is working for you.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data demo;
  input have_string $25.;
  have_string=prxchange('s/^(\d+-\d+-\d+).(\d+).(\d+).(\d+.*)$/$1T$2:$3:$4/oi',1,strip(have_string));
  have_dttm=input(strip(have_string),e8601dt26.6);

  /*Get the current timestamp*/;
  Current_time = DATETIME();

  /* subtract 14 hours (50400 seconds) */
  _14_hours_ago = intnx('dthour',current_time,-14,'s');
  datalines;
2023-09-05-06.15.16.130035
2023-09-05T06:15:16.130035
;

proc print data=demo;
  format have_dttm Current_time _14_hours_ago datetime25.6;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Sep 2023 11:07:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-to-change-DB2-timestamp-to-numeric-SAS-timestamp/m-p/892898#M39720</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-09-06T11:07:24Z</dc:date>
    </item>
    <item>
      <title>Re: Need to change DB2 timestamp to numeric SAS timestamp</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-to-change-DB2-timestamp-to-numeric-SAS-timestamp/m-p/892899#M39721</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;So it's DB2 but you are reading it from a file?&lt;/P&gt;
&lt;P&gt;If you access DB2 directly the SAS/ACCESS libname engine maps DB2 timestamps to SAS datetime auotmatically.&lt;/P&gt;
&lt;P&gt;if you can't find any suitable existing informat, you can create your own:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p0n990vq8gxca6n1vnsracr6jp2c.htm" target="_blank" rel="noopener"&gt;SAS Help Center: Syntax: PROC FORMAT PICTURE Statement&lt;/A&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Agree with your first point. ...plus rounding the floating point number to the 6th decimal.&lt;/P&gt;
&lt;P&gt;If reading a string is required: I don't believe a picture FORMAT will help as it's about the need for an INformat.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2023 11:12:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-to-change-DB2-timestamp-to-numeric-SAS-timestamp/m-p/892899#M39721</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-09-06T11:12:47Z</dc:date>
    </item>
  </channel>
</rss>

