<?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: Parsing out date from character string in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Parsing-out-date-from-character-string/m-p/615329#M18741</link>
    <description>&lt;P&gt;Perfect - thank you!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 06 Jan 2020 13:26:51 GMT</pubDate>
    <dc:creator>fordcr2</dc:creator>
    <dc:date>2020-01-06T13:26:51Z</dc:date>
    <item>
      <title>Parsing out date from character string</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Parsing-out-date-from-character-string/m-p/615324#M18739</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to parse out the date from a character string. The format of the variable (called "LogDate") is like this: 2/16/2019 12:00:00 AM. I just need the date part (2/16/2019).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My previous code worked, but it only parses out dates from 2019. Now that it is 2020, I need to include those dates as well. This is what I was using before:&amp;nbsp;&lt;/P&gt;&lt;P&gt;data providers;&lt;BR /&gt;set dsn5;&lt;/P&gt;&lt;P&gt;log_part=substr(logdate, 1, index(logdate, '2019')+3);&lt;BR /&gt;log_date=input(log_part, mmddyy10.);&lt;BR /&gt;&lt;BR /&gt;log_date=datepart(logdate);&lt;/P&gt;&lt;P&gt;format log_date mmddyy10.;&lt;BR /&gt;drop log_part logdate;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The goal is to have the variable "log_date" be the date parsed out from the character string and then formatted using mmddyy10. Please let me know what you would suggest - I couldn't figure it out using other queries from the SAS community &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TIA!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Christine&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2020 13:19:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Parsing-out-date-from-character-string/m-p/615324#M18739</guid>
      <dc:creator>fordcr2</dc:creator>
      <dc:date>2020-01-06T13:19:12Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing out date from character string</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Parsing-out-date-from-character-string/m-p/615328#M18740</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/255164"&gt;@fordcr2&lt;/a&gt;&amp;nbsp; Keeping it simple&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
char_date='2/16/2019 12:00:00 AM';
sas_date=input(char_date,mmddyy10.);
format sas_date mmddyy10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically, the idea is read 10 bytes of char with a date informat and letting the informat to convert the non-standard date to a SAS date that is numeric. Once that is done, you can format however you want&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2020 13:26:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Parsing-out-date-from-character-string/m-p/615328#M18740</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-01-06T13:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing out date from character string</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Parsing-out-date-from-character-string/m-p/615329#M18741</link>
      <description>&lt;P&gt;Perfect - thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2020 13:26:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Parsing-out-date-from-character-string/m-p/615329#M18741</guid>
      <dc:creator>fordcr2</dc:creator>
      <dc:date>2020-01-06T13:26:51Z</dc:date>
    </item>
  </channel>
</rss>

