<?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: Extract date from string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-date-from-string/m-p/730051#M227285</link>
    <description>Thank you for your help .</description>
    <pubDate>Tue, 30 Mar 2021 10:42:19 GMT</pubDate>
    <dc:creator>kaziumair</dc:creator>
    <dc:date>2021-03-30T10:42:19Z</dc:date>
    <item>
      <title>Extract date from string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-date-from-string/m-p/730036#M227272</link>
      <description>&lt;P&gt;Hi , I want to extract date from the following string&lt;/P&gt;&lt;P&gt;"&amp;lt;article id="post-13669" class="post-13669 stories type-stories status-publish has-post-thumbnail hentry category-homepage-stories tag-amab tag-amabhungane tag-dewald-van-rensburg tag-factory tag-idc tag-ikra tag-insa tag-investigative-journalism tag-kzn tag-peter-maskell-auctioneers tag-pots tag-turkey-pots" link="&lt;A href="https://amabhungane.org/stories" target="_blank"&gt;https://amabhungane.org/stories&lt;/A&gt;&lt;STRONG&gt;/210312&lt;/STRONG&gt;-funder-vs-funder-in-r500m-pots-fiasco/"&amp;gt;&lt;BR /&gt;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the date is -&amp;gt; 210312&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I extract it?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Mar 2021 10:09:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-date-from-string/m-p/730036#M227272</guid>
      <dc:creator>kaziumair</dc:creator>
      <dc:date>2021-03-30T10:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: Extract date from string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-date-from-string/m-p/730042#M227276</link>
      <description>&lt;P&gt;Brute force attack:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
string = '&amp;lt;article id="post-13669" class="post-13669 stories type-stories status-publish has-post-thumbnail hentry category-homepage-stories tag-amab tag-amabhungane tag-dewald-van-rensburg tag-factory tag-idc tag-ikra tag-insa tag-investigative-journalism tag-kzn tag-peter-maskell-auctioneers tag-pots tag-turkey-pots" link="https://amabhungane.org/stories/210312-funder-vs-funder-in-r500m-pots-fiasco/"&amp;gt;';
run;

data want;
set have;
pos = index(string,'link="https:');
substring = scan(substr(string,pos+13),-2,"/");
date = input(substr(substring,1,6),yymmdd6.);
format date yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Someone will come up with a clever application of PRXMATCH, I'm sure.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Mar 2021 10:27:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-date-from-string/m-p/730042#M227276</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-03-30T10:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: Extract date from string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-date-from-string/m-p/730043#M227277</link>
      <description>&lt;P&gt;Most likely by using a regular expression. For the text you have posted the expression&lt;/P&gt;
&lt;PRE&gt;\/(\d{6})\D&lt;/PRE&gt;
&lt;P&gt;seems ok.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See docs of prxmatch, prxparse and prxposn for details.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Mar 2021 10:28:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-date-from-string/m-p/730043#M227277</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-03-30T10:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: Extract date from string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-date-from-string/m-p/730044#M227278</link>
      <description>&lt;P&gt;Hi, one way would be to use regexp to find 6 numbers in a row or maybe /followed by 6 numbers then you have your date. Further I would split the string into year, month day as numbers and use the yymmdd function. You may also try anydtdte. informat.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Mar 2021 10:29:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-date-from-string/m-p/730044#M227278</guid>
      <dc:creator>PaalNavestad</dc:creator>
      <dc:date>2021-03-30T10:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: Extract date from string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-date-from-string/m-p/730045#M227279</link>
      <description>&lt;P&gt;As predicted &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Mar 2021 10:29:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-date-from-string/m-p/730045#M227279</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-03-30T10:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: Extract date from string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-date-from-string/m-p/730046#M227280</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Don't&lt;/STRONG&gt; use the ANY* informats for strings where the date structure is not very clear. With the given string, you might end up with 2012-03-21 or 2021-03-12, depending on locale of the SAS session.&lt;/P&gt;
&lt;P&gt;Since you can only use the ANY* informats reliably when the structure is clear already, you never use them, unless you want unpredictable results.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Mar 2021 10:35:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-date-from-string/m-p/730046#M227280</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-03-30T10:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: Extract date from string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-date-from-string/m-p/730050#M227284</link>
      <description>Hi , Thanks for your suggestion , I will check the docs mentioned</description>
      <pubDate>Tue, 30 Mar 2021 10:41:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-date-from-string/m-p/730050#M227284</guid>
      <dc:creator>kaziumair</dc:creator>
      <dc:date>2021-03-30T10:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: Extract date from string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-date-from-string/m-p/730051#M227285</link>
      <description>Thank you for your help .</description>
      <pubDate>Tue, 30 Mar 2021 10:42:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-date-from-string/m-p/730051#M227285</guid>
      <dc:creator>kaziumair</dc:creator>
      <dc:date>2021-03-30T10:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: Extract date from string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-date-from-string/m-p/730080#M227293</link>
      <description>&lt;PRE&gt;data want;
set have;
p=prxmatch('/(?&amp;lt;=\/)\d/',string);
if p then want=substr(string,p,6);
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Mar 2021 13:17:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-date-from-string/m-p/730080#M227293</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-03-30T13:17:26Z</dc:date>
    </item>
  </channel>
</rss>

