<?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: Extracting and converting dates in strings to new date string in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Extracting-and-converting-dates-in-strings-to-new-date-string/m-p/618608#M19246</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data test;
dt='January 14, 2020 12:25:02';/*string*/
num_dt=input(dt,anydtdtm35.);/*numeric datetime value*/
/*Extract date value, time value and concatenate to a new string value*/
want_date=cats(put(datepart(num_dt),yymmddn8.),'_',compress(put(timepart(num_dt),hhmm.),':'));
drop num_dt;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 20 Jan 2020 16:59:36 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2020-01-20T16:59:36Z</dc:date>
    <item>
      <title>Extracting and converting dates in strings to new date string</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-and-converting-dates-in-strings-to-new-date-string/m-p/618602#M19244</link>
      <description>&lt;P&gt;I have some code which works to extract the Last Modified date from an excel file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; last_mod_date;&lt;/P&gt;&lt;P&gt;&amp;nbsp; rc = filename("onefile","F:\test.xlsx");&lt;/P&gt;&lt;P&gt;&amp;nbsp; fid=fopen("onefile"); /*fid is the file-id*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; Mod_Date=finfo(fid,'Last Modified');&lt;/P&gt;&lt;P&gt;&amp;nbsp; rc = fclose(fid);&lt;/P&gt;&lt;P&gt;&amp;nbsp; rc = filename("onefile");&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data is stored as at 200 character length as the following&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;January 14, 2020 12:25:02&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I want to take the above and convert it to the following string&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;YYYYMMDD_HHMM&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried several difference methods to try and extract the month/day/year/hours/minutes individually but none of them seem to work. Any ideas?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Note; I need this to work for any string date I extract (dates will be after January 1, 2020 if that helps)&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2020 16:39:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-and-converting-dates-in-strings-to-new-date-string/m-p/618602#M19244</guid>
      <dc:creator>NickK</dc:creator>
      <dc:date>2020-01-20T16:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting and converting dates in strings to new date string</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-and-converting-dates-in-strings-to-new-date-string/m-p/618608#M19246</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data test;
dt='January 14, 2020 12:25:02';/*string*/
num_dt=input(dt,anydtdtm35.);/*numeric datetime value*/
/*Extract date value, time value and concatenate to a new string value*/
want_date=cats(put(datepart(num_dt),yymmddn8.),'_',compress(put(timepart(num_dt),hhmm.),':'));
drop num_dt;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Jan 2020 16:59:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-and-converting-dates-in-strings-to-new-date-string/m-p/618608#M19246</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-01-20T16:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting and converting dates in strings to new date string</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-and-converting-dates-in-strings-to-new-date-string/m-p/618627#M19251</link>
      <description>Thanks. Works perfectly.</description>
      <pubDate>Mon, 20 Jan 2020 17:50:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-and-converting-dates-in-strings-to-new-date-string/m-p/618627#M19251</guid>
      <dc:creator>NickK</dc:creator>
      <dc:date>2020-01-20T17:50:39Z</dc:date>
    </item>
  </channel>
</rss>

