<?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: find DOB within a Character field in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/find-DOB-within-a-Character-field/m-p/370482#M88473</link>
    <description>&lt;P&gt;Is Date of Birth always 10 characters e.g. 01/07/1947 or can it be less e.g. 1/7/1947?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once we know that it should be a relatively simple to write something to extact the values&lt;/P&gt;</description>
    <pubDate>Mon, 26 Jun 2017 10:58:09 GMT</pubDate>
    <dc:creator>ChrisBrooks</dc:creator>
    <dc:date>2017-06-26T10:58:09Z</dc:date>
    <item>
      <title>find DOB within a Character field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-DOB-within-a-Character-field/m-p/370470#M88469</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am need of your help yet again...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have a character field (1024) which contains a DOB which looks like this: &amp;nbsp;- Date of Birth: 23/09/1947&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to extract the DOB from the charachter field, so i can compare it to another DOB and go from there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;They date of birth is always formated&amp;nbsp;as above, with the &amp;nbsp;"&lt;SPAN&gt;- Date of Birth:" &amp;nbsp;part there too.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have been trying to use the "- Date of Birth:" as a delimiter, so i can then select the actual date from the field. &amp;nbsp;I dont know where in the field it will appear, but it is always formatted as above.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I've been looking at Scan, Find and Index, but I'm not getting very far.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Could I ask if any one has any recomendations for me to try?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;thank,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;paul&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 10:42:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-DOB-within-a-Character-field/m-p/370470#M88469</guid>
      <dc:creator>pandhandj</dc:creator>
      <dc:date>2017-06-26T10:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: find DOB within a Character field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-DOB-within-a-Character-field/m-p/370481#M88472</link>
      <description>&lt;P&gt;You might use this as a blueprint:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input field $80.;
cards;
which contains a DOB which looks like this:  - Date of Birth: 23/09/1947
;
run;

data want;
set have;
i = index(field,"- Date of Birth: ");
dob = input(substr(field,i+17,10),ddmmyy10.);
format dob ddmmyy10.;
drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Jun 2017 10:58:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-DOB-within-a-Character-field/m-p/370481#M88472</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-06-26T10:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: find DOB within a Character field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-DOB-within-a-Character-field/m-p/370482#M88473</link>
      <description>&lt;P&gt;Is Date of Birth always 10 characters e.g. 01/07/1947 or can it be less e.g. 1/7/1947?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once we know that it should be a relatively simple to write something to extact the values&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 10:58:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-DOB-within-a-Character-field/m-p/370482#M88473</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2017-06-26T10:58:09Z</dc:date>
    </item>
    <item>
      <title>Re: find DOB within a Character field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-DOB-within-a-Character-field/m-p/370483#M88474</link>
      <description>&lt;P&gt;Assuming it is always that and the date is 10 characters:&lt;/P&gt;
&lt;PRE&gt;data test;
  old_str="abc def llakfjfj  - Date of Birth: 23/09/1947  xyz b";
  dob_txt=substr(old_str,index(old_str,'- Date of Birth:') + 17,10);
run;
&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Jun 2017 10:58:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-DOB-within-a-Character-field/m-p/370483#M88474</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-26T10:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: find DOB within a Character field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-DOB-within-a-Character-field/m-p/370484#M88475</link>
      <description>&lt;P&gt;Something like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
charDOB = "- Date of Birth: 23/09/1947";
DOB = input(strip(tranwrd(charDOB, "- Date of Birth: ", "")), ddmmyy10.);
format DOB ddmmyy10.;
put DOB;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Jun 2017 10:58:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-DOB-within-a-Character-field/m-p/370484#M88475</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-06-26T10:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: find DOB within a Character field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-DOB-within-a-Character-field/m-p/370508#M88486</link>
      <description>&lt;P&gt;All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you very much for your reposnes, it really is appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have been concentrating on Kurt's suggestion, but i still have an issue -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it looks like the index statement is stopping when it hits the first blank space (" ") in my&amp;nbsp;field, thus giveing a null DOB.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i.e - quite a few of these files begin with a date stamp like this -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[Jun&amp;nbsp; 8 2017&amp;nbsp; 9:42AM by Smith, A]&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;blah blah blah&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;- Date of Birth: dd/mm/yyy&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;bla, blah, blah&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when i use the index statement like this: &amp;nbsp;i = index(field,"- Date of Birth: "); &amp;nbsp;i get a null&amp;nbsp;return in the i field&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if i change it to&amp;nbsp;&lt;SPAN&gt;i = index(field,"[JUN"); I get a 1 in the i field&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;but if i change it to =&amp;nbsp;i = index(field,"[JUN 8"); i get a null result.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;what am i doing wrong this time?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;thanks again,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;paul&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 12:37:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-DOB-within-a-Character-field/m-p/370508#M88486</guid>
      <dc:creator>pandhandj</dc:creator>
      <dc:date>2017-06-26T12:37:41Z</dc:date>
    </item>
    <item>
      <title>Re: find DOB within a Character field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-DOB-within-a-Character-field/m-p/370514#M88489</link>
      <description>&lt;P&gt;When you use the index() function, the &lt;EM&gt;excerpt&lt;/EM&gt; (see the documentation) must appear exactly as used.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;index("[Jun  8 2017","[Jun 8")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;will return zero, while&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;[index("[Jun  8 2017","Jun  8")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;will return 1.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 12:48:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-DOB-within-a-Character-field/m-p/370514#M88489</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-06-26T12:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: find DOB within a Character field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-DOB-within-a-Character-field/m-p/370531#M88495</link>
      <description>&lt;P&gt;Kurt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you are right on the money, again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i had a leading " " in my text.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks too all for taking the time to help me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;paul&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 13:15:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-DOB-within-a-Character-field/m-p/370531#M88495</guid>
      <dc:creator>pandhandj</dc:creator>
      <dc:date>2017-06-26T13:15:31Z</dc:date>
    </item>
    <item>
      <title>Re: find DOB within a Character field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-DOB-within-a-Character-field/m-p/370557#M88504</link>
      <description>&lt;P&gt;using regular expressions you can do this way&lt;/P&gt;
&lt;PRE&gt;data want;
set have;
dob = input(prxchange( 's/.*(\d{2}\/\d{2}\/\d{4}).*/$1/', -1, field), ddmmyy10.);
format dob ddmmyy10.;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Jun 2017 13:38:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-DOB-within-a-Character-field/m-p/370557#M88504</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-06-26T13:38:00Z</dc:date>
    </item>
  </channel>
</rss>

