<?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 Pulling all characters/numbers out of a string in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Pulling-all-characters-numbers-out-of-a-string/m-p/535226#M73914</link>
    <description>&lt;P&gt;So I have a variable in my dataset that combines letters and numbers without a defined pattern.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;ID&amp;nbsp;&lt;/U&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;U&gt;Name&lt;/U&gt;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; G1CA&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;ST10C&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Unit8&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10A&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to parse out the characters and numbers in the strings within the groupings which they occur so for ID #1 I'd like it to provide 3 additional columns, Col1 containing "G", Col2 containing 1, and Col3 containing "CA".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been looking into the "ANYALPHA" and "NOTALPHA" which returns the first position of the character or number which I could then possibly combine with a substr function?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am hoping there is something a little more straightforward?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Feb 2019 15:35:44 GMT</pubDate>
    <dc:creator>xezus</dc:creator>
    <dc:date>2019-02-13T15:35:44Z</dc:date>
    <item>
      <title>Pulling all characters/numbers out of a string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pulling-all-characters-numbers-out-of-a-string/m-p/535226#M73914</link>
      <description>&lt;P&gt;So I have a variable in my dataset that combines letters and numbers without a defined pattern.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;ID&amp;nbsp;&lt;/U&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;U&gt;Name&lt;/U&gt;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; G1CA&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;ST10C&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Unit8&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10A&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to parse out the characters and numbers in the strings within the groupings which they occur so for ID #1 I'd like it to provide 3 additional columns, Col1 containing "G", Col2 containing 1, and Col3 containing "CA".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been looking into the "ANYALPHA" and "NOTALPHA" which returns the first position of the character or number which I could then possibly combine with a substr function?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am hoping there is something a little more straightforward?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 15:35:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pulling-all-characters-numbers-out-of-a-string/m-p/535226#M73914</guid>
      <dc:creator>xezus</dc:creator>
      <dc:date>2019-02-13T15:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling all characters/numbers out of a string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pulling-all-characters-numbers-out-of-a-string/m-p/535237#M73915</link>
      <description>&lt;P&gt;Simplest way to get only letters or only numbers is by using compress with the appropriate options:&lt;/P&gt;
&lt;PRE&gt;data want;
  array c{20} $1;
  array n{20} 8;
  str="G1CA";
  chars=compress(str," ","ka");
  nums=compress(str," ","kd");
  do i=1 to lengthn(chars);
    c{i}=char(chars,i);
  end;
  do i=1 to lengthn(nums);
    n{i}=char(nums,i);
  end;
run;
&lt;/PRE&gt;
&lt;P&gt;That will split out each alpha to c{*} array and each number to n{*} - note max 20 of each (I don't know how long for maximum so went for 20).&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 15:48:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pulling-all-characters-numbers-out-of-a-string/m-p/535237#M73915</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-02-13T15:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling all characters/numbers out of a string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pulling-all-characters-numbers-out-of-a-string/m-p/535244#M73916</link>
      <description>&lt;P&gt;That works perfectly! I can play around with concatenating the characters into strings to get all possible combinations, luckily my max name length is only 6.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 16:02:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pulling-all-characters-numbers-out-of-a-string/m-p/535244#M73916</guid>
      <dc:creator>xezus</dc:creator>
      <dc:date>2019-02-13T16:02:29Z</dc:date>
    </item>
  </channel>
</rss>

