<?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: Searching a character string for embedded numbers in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Searching-a-character-string-for-embedded-numbers/m-p/296390#M62083</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
length var $ 50;
input var $;
seq=scan(var,2,'0123456789','k');
cards;
14025/1258/669     
145890/0048/4458   
1212/1-1515        
14589/49/1247      
124/12458/1        
4545-00001-999     
45*784CH21         
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 04 Sep 2016 16:39:28 GMT</pubDate>
    <dc:creator>Haikuo</dc:creator>
    <dc:date>2016-09-04T16:39:28Z</dc:date>
    <item>
      <title>Searching a character string for embedded numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Searching-a-character-string-for-embedded-numbers/m-p/296384#M62080</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have a string variable (var) that contains a sequence of characters or numbers. I wish to assign&amp;nbsp;to another to variable (seq)&amp;nbsp;a&amp;nbsp;sequence of numbers that are embedded in&amp;nbsp;this number, usually between&amp;nbsp;two non-numeric delimiters&amp;nbsp;(e.g., '/' or '-'). For example, &amp;nbsp;var=14025/1258/669. I would like save to seq the charater 1258. The problem that I have is the first set of numbers vary in length as does the seq I want to save.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a theoretical database;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;var &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;seq (I want to&amp;nbsp;save)&lt;/P&gt;
&lt;P&gt;--- &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; ------------------------&lt;/P&gt;
&lt;P&gt;14025/1258/669 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1258&lt;/P&gt;
&lt;P&gt;145890/0048/4458 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0048&lt;/P&gt;
&lt;P&gt;1212/1-1515 &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; 1&lt;/P&gt;
&lt;P&gt;14589/49/1247 &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; 49&lt;/P&gt;
&lt;P&gt;124/12458/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; &amp;nbsp; 12458&lt;/P&gt;
&lt;P&gt;4545-00001-999 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 00001&lt;/P&gt;
&lt;P&gt;45*784CH21 &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; 784&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think SAS string functions may help (e.g., find, index). If anyone can solve I'd appreciate as always.&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using 9.4, 64-bit under Windows 7&lt;/P&gt;
&lt;P&gt;--Tim&lt;/P&gt;</description>
      <pubDate>Sun, 04 Sep 2016 13:46:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Searching-a-character-string-for-embedded-numbers/m-p/296384#M62080</guid>
      <dc:creator>tallkell</dc:creator>
      <dc:date>2016-09-04T13:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a character string for embedded numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Searching-a-character-string-for-embedded-numbers/m-p/296390#M62083</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
length var $ 50;
input var $;
seq=scan(var,2,'0123456789','k');
cards;
14025/1258/669     
145890/0048/4458   
1212/1-1515        
14589/49/1247      
124/12458/1        
4545-00001-999     
45*784CH21         
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 04 Sep 2016 16:39:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Searching-a-character-string-for-embedded-numbers/m-p/296390#M62083</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2016-09-04T16:39:28Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a character string for embedded numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Searching-a-character-string-for-embedded-numbers/m-p/296433#M62108</link>
      <description>&lt;P&gt;Regular expressions pattern matching is&amp;nbsp;well suited&amp;nbsp;for this kind of task:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input var :$32. wantSeq :$12.;
datalines;
14025/1258/669 1258
145890/0048/4458 0048
1212/1-1515 1
14589/49/1247 49
124/12458/1 12458
4545-00001-999 00001
45*784CH21 784
;

data want;
set have;
length seq $12;
seq = prxchange("s#\D*\d+[^0-9]+(\d+)[^0-9]+.*#\1#o", 1, var);
run;


proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Sep 2016 02:37:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Searching-a-character-string-for-embedded-numbers/m-p/296433#M62108</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-09-05T02:37:55Z</dc:date>
    </item>
  </channel>
</rss>

