<?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: Convert string to timestamp in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-string-to-timestamp/m-p/802474#M315917</link>
    <description>&lt;P&gt;I really do not like the vagaries of the "ANY" informats, so I force correct informats for the date and time part:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input beginn $20.;
datalines;
14.03.2022 08:00:50
;

data want;
set have (rename=(beginn=_beginn));
format beginn e8601dt19.;
beginn = dhms(
  input(scan(_beginn,1," "),ddmmyy10.),
  0,
  0,
  input(scan(_beginn,2," "),time8.)
);
drop _beginn;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 16 Mar 2022 12:22:17 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-03-16T12:22:17Z</dc:date>
    <item>
      <title>Convert string to timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-string-to-timestamp/m-p/802453#M315904</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;this is my string&amp;nbsp;&lt;STRONG&gt;14.03.2022 08:00:50 &lt;/STRONG&gt;&lt;EM&gt;Input is $20&lt;/EM&gt;. How to convert this string to timestamp?&lt;/P&gt;&lt;P&gt;The code below give back empty field BEGINN.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;  data &amp;amp;wkLibname..F_DATA;
    format
      BEGINN_TMP DATETIME26.;
    set &amp;amp;wkLibname..DATA_RAW;
      BEGINN_TMP = input(BEGINN, NLDATM.);
      DROP BEGINN;
      RENAME BEGINN_TMP = BEGINN;
  run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 10:47:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-string-to-timestamp/m-p/802453#M315904</guid>
      <dc:creator>Hansmuffs</dc:creator>
      <dc:date>2022-03-16T10:47:19Z</dc:date>
    </item>
    <item>
      <title>Re: Convert string to timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-string-to-timestamp/m-p/802459#M315906</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input beginn $20.;
datalines;
14.03.2022 08:00:50
;
run;

data want;
	set have;
		beginn_tmp = input(beginn, ANYDTDTM.);
	format beginn_tmp datetime19.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="maguiremq_0-1647428793821.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69508iE35B6CF22301DBD7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="maguiremq_0-1647428793821.png" alt="maguiremq_0-1647428793821.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Remove the FORMAT if you don't want it formatted.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 11:07:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-string-to-timestamp/m-p/802459#M315906</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2022-03-16T11:07:07Z</dc:date>
    </item>
    <item>
      <title>Re: Convert string to timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-string-to-timestamp/m-p/802474#M315917</link>
      <description>&lt;P&gt;I really do not like the vagaries of the "ANY" informats, so I force correct informats for the date and time part:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input beginn $20.;
datalines;
14.03.2022 08:00:50
;

data want;
set have (rename=(beginn=_beginn));
format beginn e8601dt19.;
beginn = dhms(
  input(scan(_beginn,1," "),ddmmyy10.),
  0,
  0,
  input(scan(_beginn,2," "),time8.)
);
drop _beginn;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Mar 2022 12:22:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-string-to-timestamp/m-p/802474#M315917</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-16T12:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: Convert string to timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-string-to-timestamp/m-p/802491#M315927</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/305587"&gt;@Hansmuffs&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code should work well &lt;EM&gt;if&lt;/EM&gt; you are using the typical German setting of system option LOCALE, i.e.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options locale=DE_DE;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It also works with some other locales, e.g., FR_FR or EN_GB, but not with EN_US (which in turn works with &lt;FONT face="courier new,courier"&gt;'&lt;EM&gt;03.14&lt;/EM&gt;.2022 08:00:50'&lt;/FONT&gt;).&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 13:30:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-string-to-timestamp/m-p/802491#M315927</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-03-16T13:30:05Z</dc:date>
    </item>
  </channel>
</rss>

