<?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: How to select a date from a string conditional on a part of that string in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-select-a-date-from-a-string-conditional-on-a-part-of-that/m-p/168221#M3263</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you for replying and for reading my previous question!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to ask a question, suppose I had ABC ( merged in 1/10/2012 because of reasons), when applying the scan function the "date" that I will get is "reasons" because its the last word, so is there a way of getting the date regardless of its position in the string?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 04 Jan 2015 05:14:36 GMT</pubDate>
    <dc:creator>ilikesas</dc:creator>
    <dc:date>2015-01-04T05:14:36Z</dc:date>
    <item>
      <title>How to select a date from a string conditional on a part of that string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-select-a-date-from-a-string-conditional-on-a-part-of-that/m-p/168219#M3261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;suppose I have the following table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="144" style="border: 1px solid rgb(0, 0, 0); width: 201px; height: 146px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Company&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;ABC (merged 1/10/2012)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;DEF (bankrupt 2/5/2009)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;ZZZ&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the company merged, I would like to get a new column for the date when it happened, and nothing for the others, in the following way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="113" style="border: 1px solid rgb(0, 0, 0); width: 391px; height: 115px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Company&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Merged&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;ABC (merged 1/10/2012)&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1/10/2012&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;DEF (bankrupt 2/5/2009)&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;ZZZ&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Jan 2015 02:04:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-select-a-date-from-a-string-conditional-on-a-part-of-that/m-p/168219#M3261</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2015-01-04T02:04:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to select a date from a string conditional on a part of that string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-select-a-date-from-a-string-conditional-on-a-part-of-that/m-p/168220#M3262</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're previous questions should allow you to isolate which variables have the word merged. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Adding on to that, you can use the scan function to get the date, and in conjunction with the input function convert it to a valid SAS date which is highly recommended. I'm assuming the format of the dates is mmddyy though it's unclear based on your date format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: Consolas;"&gt;&lt;SPAN style="color: #042eeb;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; have;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: Consolas;"&gt;&lt;SPAN style="color: #042eeb;"&gt;length&lt;/SPAN&gt; var &lt;SPAN style="color: #009193;"&gt;$30.&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: Consolas; color: #942193;"&gt;&lt;SPAN style="color: #000000;"&gt;var=&lt;/SPAN&gt;"ABC (merged 1/10/2012)"&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="color: #042eeb;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: Consolas; color: #942193;"&gt;&lt;SPAN style="color: #000000;"&gt;var=&lt;/SPAN&gt;"DEF (bankrupt 2/5/2009)"&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="color: #042eeb;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: Consolas;"&gt;var=&lt;SPAN style="color: #942193;"&gt;"ZZZ"&lt;/SPAN&gt;;&lt;SPAN style="color: #042eeb;"&gt;output&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: Consolas; color: #042eeb;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: Consolas;"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: Consolas;"&gt;&lt;SPAN style="color: #042eeb;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; want;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: Consolas;"&gt;&lt;SPAN style="color: #042eeb;"&gt;set&lt;/SPAN&gt; have;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: Consolas;"&gt;date=scan(var, -&lt;SPAN style="color: #942193;"&gt;1&lt;/SPAN&gt;, &lt;SPAN style="color: #942193;"&gt;"() "&lt;/SPAN&gt;);&lt;/P&gt;&lt;P style="font-size: 10px; font-family: Consolas;"&gt;sas_date=input(scan(var, -&lt;SPAN style="color: #942193;"&gt;1&lt;/SPAN&gt;, &lt;SPAN style="color: #942193;"&gt;"() "&lt;/SPAN&gt;), &lt;SPAN style="color: #009193;"&gt;mmddyy10.&lt;/SPAN&gt;);&lt;/P&gt;&lt;P style="font-size: 10px; font-family: Consolas;"&gt;&lt;SPAN style="color: #042eeb;"&gt;format&lt;/SPAN&gt; sas_date &lt;SPAN style="color: #009193;"&gt;date9.&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: Consolas; color: #042eeb;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #942193;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Jan 2015 04:24:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-select-a-date-from-a-string-conditional-on-a-part-of-that/m-p/168220#M3262</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-01-04T04:24:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to select a date from a string conditional on a part of that string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-select-a-date-from-a-string-conditional-on-a-part-of-that/m-p/168221#M3263</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you for replying and for reading my previous question!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to ask a question, suppose I had ABC ( merged in 1/10/2012 because of reasons), when applying the scan function the "date" that I will get is "reasons" because its the last word, so is there a way of getting the date regardless of its position in the string?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Jan 2015 05:14:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-select-a-date-from-a-string-conditional-on-a-part-of-that/m-p/168221#M3263</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2015-01-04T05:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to select a date from a string conditional on a part of that string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-select-a-date-from-a-string-conditional-on-a-part-of-that/m-p/168222#M3264</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Any other variations? Will there be other numbers or slashes in the text? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can look into the index/find/substr functions. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Jan 2015 06:31:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-select-a-date-from-a-string-conditional-on-a-part-of-that/m-p/168222#M3264</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-01-04T06:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to select a date from a string conditional on a part of that string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-select-a-date-from-a-string-conditional-on-a-part-of-that/m-p/168223#M3265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would go for Perl regular expression functions: E.g. PRXCHANGE, PRXMATCH etc. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Jan 2015 07:11:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-select-a-date-from-a-string-conditional-on-a-part-of-that/m-p/168223#M3265</guid>
      <dc:creator>OleSteen</dc:creator>
      <dc:date>2015-01-04T07:11:26Z</dc:date>
    </item>
  </channel>
</rss>

