<?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 extract a number from a character string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-number-from-a-character-string/m-p/288447#M59493</link>
    <description>&lt;P&gt;Below some options:&lt;/P&gt;
&lt;PRE&gt;data have;&lt;BR /&gt; infile datalines dsd;&lt;BR /&gt; input ID indi $50.;&lt;BR /&gt; /* simple way if you can be sure that there is only one number in the string */&lt;BR /&gt; want1=input(compress(indi,,'kd'),?? best32.);&lt;BR /&gt;&lt;BR /&gt; /* option 2: use -AE as token */&lt;BR /&gt; want2=input(substr(indi,find(indi,'-AE','i')+3),?? best32.);&lt;BR /&gt;&lt;BR /&gt; /* or with a RegEx if the pattern is a bit more complicated*/&lt;BR /&gt; retain _rxID;&lt;BR /&gt; if _n_=1 then _rxID=prxparse('/-AE(\d+)/oi');&lt;BR /&gt; if prxmatch(_rxID, indi) then&lt;BR /&gt; do;&lt;BR /&gt; want3=input(prxposn(_rxID, 1, indi),?? best32.);&lt;BR /&gt; end;&lt;BR /&gt;&lt;BR /&gt; datalines;&lt;BR /&gt;1,Any EVENT, SPECIFY*-AE1&lt;BR /&gt;2,Among EVENT, SPECIFY*-AE2&lt;BR /&gt;2,Among EVENT, SPECIFY*-AE34and something else 77&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 01 Aug 2016 03:56:09 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2016-08-01T03:56:09Z</dc:date>
    <item>
      <title>How to extract a number from a character string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-number-from-a-character-string/m-p/288445#M59492</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;&lt;P&gt;I need to a create a new variable in a dataset from two datasets.&lt;/P&gt;&lt;P&gt;The number in &amp;nbsp;indi &lt;SPAN&gt;(dataset1)&lt;/SPAN&gt;&amp;nbsp;variable must match with &amp;nbsp;pid &lt;SPAN&gt;(dataset2)&amp;nbsp;&lt;/SPAN&gt;variable value and then the CMINAE should be concatenation of AE||#||PID||TERM.&lt;BR /&gt;How to extract the number from indi variable. The indi variable values are different lengths. Please help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dataset1&lt;/P&gt;&lt;P&gt;ID &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;indi&lt;BR /&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Any EVENT, SPECIFY*-AE1&lt;BR /&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Among EVENT, SPECIFY*-AE2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;dataset2&lt;BR /&gt;id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;term &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;pid&lt;BR /&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;TOOTHACHE &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;HEADACHE &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;BR /&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SINUSITIS &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;INFECTION &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OUTPUT NEEDED.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATASET3;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ID &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; indi &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CMINAE&lt;BR /&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Any EVENT, SPECIFY*-AE1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AE#1 TOOTHACHE&lt;BR /&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Any EVENT, SPECIFY*-AE2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AE#2 INFECTION&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2016 03:23:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-number-from-a-character-string/m-p/288445#M59492</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2016-08-01T03:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a number from a character string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-number-from-a-character-string/m-p/288447#M59493</link>
      <description>&lt;P&gt;Below some options:&lt;/P&gt;
&lt;PRE&gt;data have;&lt;BR /&gt; infile datalines dsd;&lt;BR /&gt; input ID indi $50.;&lt;BR /&gt; /* simple way if you can be sure that there is only one number in the string */&lt;BR /&gt; want1=input(compress(indi,,'kd'),?? best32.);&lt;BR /&gt;&lt;BR /&gt; /* option 2: use -AE as token */&lt;BR /&gt; want2=input(substr(indi,find(indi,'-AE','i')+3),?? best32.);&lt;BR /&gt;&lt;BR /&gt; /* or with a RegEx if the pattern is a bit more complicated*/&lt;BR /&gt; retain _rxID;&lt;BR /&gt; if _n_=1 then _rxID=prxparse('/-AE(\d+)/oi');&lt;BR /&gt; if prxmatch(_rxID, indi) then&lt;BR /&gt; do;&lt;BR /&gt; want3=input(prxposn(_rxID, 1, indi),?? best32.);&lt;BR /&gt; end;&lt;BR /&gt;&lt;BR /&gt; datalines;&lt;BR /&gt;1,Any EVENT, SPECIFY*-AE1&lt;BR /&gt;2,Among EVENT, SPECIFY*-AE2&lt;BR /&gt;2,Among EVENT, SPECIFY*-AE34and something else 77&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2016 03:56:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-number-from-a-character-string/m-p/288447#M59493</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-08-01T03:56:09Z</dc:date>
    </item>
  </channel>
</rss>

