<?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 Compress part of a string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33668#M6600</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think that you will need a prxchange solution, but will have to wait until someone posts one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You simply want to change the sequence of a space, followed by, &lt;/P&gt;&lt;P&gt;u&lt;/P&gt;&lt;P&gt;followed by: 0 or more spaces&lt;/P&gt;&lt;P&gt;followed by u&lt;/P&gt;&lt;P&gt;followed by: 0 or more spaces&lt;/P&gt;&lt;P&gt;followed by n&lt;/P&gt;&lt;P&gt;followed by: 0 or more spaces&lt;/P&gt;&lt;P&gt;followed by e&lt;/P&gt;&lt;P&gt;followed by: 0 or more spaces&lt;/P&gt;&lt;P&gt;followed by t&lt;/P&gt;&lt;P&gt;followed by: 1 or more spaces&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and change it to&lt;/P&gt;&lt;P&gt;space&lt;/P&gt;&lt;P&gt;uunet&lt;/P&gt;&lt;P&gt;space&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately, I don't know how to write that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 19 Jan 2012 18:45:59 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2012-01-19T18:45:59Z</dc:date>
    <item>
      <title>Compress part of a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33662#M6594</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;I am trying to find a way to compress part of a string and cannot think of an easy way to do it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have string with values of "word1 x y z word2 word3" and would like to have the result be "word1 xyz word2 word3".&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;doug&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jan 2012 16:57:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33662#M6594</guid>
      <dc:creator>DougE</dc:creator>
      <dc:date>2012-01-19T16:57:17Z</dc:date>
    </item>
    <item>
      <title>Compress part of a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33663#M6595</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Doug,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As always, I am sure that there are a number of ways to do what you want.&amp;nbsp; E.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat string $50.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input string &amp;amp;;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;word1 word2 x y z word3&lt;/P&gt;&lt;P&gt;this x y z that something else&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (keep=string);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array parts(5) $10.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; i=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; j=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; k=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do while (scan(string,i) ne "");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if length(scan(string,i)) gt 1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; j=j+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; parts(j)=scan(string,i);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; k=k+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if k eq 1 then j=j+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; parts(j)=catt(parts(j),scan(string,i));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; i=i+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; string=catx(' ',of parts(*));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jan 2012 17:20:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33663#M6595</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-01-19T17:20:44Z</dc:date>
    </item>
    <item>
      <title>Compress part of a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33664#M6596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are there always 6 words and words 2,3,4 are compressed? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jan 2012 17:40:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33664#M6596</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2012-01-19T17:40:10Z</dc:date>
    </item>
    <item>
      <title>Compress part of a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33665#M6597</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, the number of words may vary and the the portion of the string may vary as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The string I'd like to compress may have 3 or more characters&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;x y z a b&lt;/P&gt;&lt;P&gt;word1 xyz a b&amp;nbsp; word2 &lt;/P&gt;&lt;P&gt;x yz a b word1 word2 ... word6&lt;/P&gt;&lt;P&gt;word1 word2 x y zab&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for being unclear in the inital post&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jan 2012 17:45:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33665#M6597</guid>
      <dc:creator>DougE</dc:creator>
      <dc:date>2012-01-19T17:45:50Z</dc:date>
    </item>
    <item>
      <title>Compress part of a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33666#M6598</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Still not clear then!&amp;nbsp; What differentiates the words that should and shouldn't be compressed?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jan 2012 17:53:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33666#M6598</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-01-19T17:53:02Z</dc:date>
    </item>
    <item>
      <title>Compress part of a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33667#M6599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I know the sequence of characters that I want to compress. I am looking at internet search data and not everyone searches for a given company in the same way.&amp;nbsp; So, if I were interested in UUNET users may type in U U NET, UU NET, U UNET, etc.&amp;nbsp; The solution I am looking for does not have to pick up the instances where the characters are transposed (since the vast majority will put the characters in the correct order) just the instances where the charaters are in the 'right' order but the spacing is different.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jan 2012 18:10:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33667#M6599</guid>
      <dc:creator>DougE</dc:creator>
      <dc:date>2012-01-19T18:10:39Z</dc:date>
    </item>
    <item>
      <title>Compress part of a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33668#M6600</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think that you will need a prxchange solution, but will have to wait until someone posts one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You simply want to change the sequence of a space, followed by, &lt;/P&gt;&lt;P&gt;u&lt;/P&gt;&lt;P&gt;followed by: 0 or more spaces&lt;/P&gt;&lt;P&gt;followed by u&lt;/P&gt;&lt;P&gt;followed by: 0 or more spaces&lt;/P&gt;&lt;P&gt;followed by n&lt;/P&gt;&lt;P&gt;followed by: 0 or more spaces&lt;/P&gt;&lt;P&gt;followed by e&lt;/P&gt;&lt;P&gt;followed by: 0 or more spaces&lt;/P&gt;&lt;P&gt;followed by t&lt;/P&gt;&lt;P&gt;followed by: 1 or more spaces&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and change it to&lt;/P&gt;&lt;P&gt;space&lt;/P&gt;&lt;P&gt;uunet&lt;/P&gt;&lt;P&gt;space&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately, I don't know how to write that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jan 2012 18:45:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33668#M6600</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-01-19T18:45:59Z</dc:date>
    </item>
    <item>
      <title>Compress part of a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33669#M6601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the suggestion!&amp;nbsp; I found a very helpful paper at &lt;A href="http://www2.sas.com/proceedings/sugi29/129-29.pdf"&gt;http://www2.sas.com/proceedings/sugi29/129-29.pdf&lt;/A&gt; that describes the prx functions and I'm sure that I can figure it out from there.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jan 2012 19:55:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33669#M6601</guid>
      <dc:creator>DougE</dc:creator>
      <dc:date>2012-01-19T19:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: Compress part of a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33670#M6602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The following does, I think, what you want.&amp;nbsp; I'm sure that it could be written better:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat string $50.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input string &amp;amp;;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;word1 word2 u u net word3&lt;/P&gt;&lt;P&gt;this uu net that something else&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; want=prxchange('s/[ ][uU][ ]{0,1}[uU][ ]{0,1}[nN][ ]{0,1}[eE][ ]{0,1}[tT][ ]/ uunet /',-1,strip(string));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jan 2012 20:08:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33670#M6602</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-01-19T20:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: Compress part of a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33671#M6603</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Art.&lt;/P&gt;&lt;P&gt;I think it is very difficult. you do not know when to stop combining these single character.&lt;/P&gt;&lt;P&gt;x y z a b&amp;nbsp;&amp;nbsp; ----&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xy zab ?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xyz ab ?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xyza b&amp;nbsp; ?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xyzab ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A workaround is using a dictionary then look it up to see whether the combination of these characters&amp;nbsp; is a real word.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Jan 2012 04:48:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33671#M6603</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-01-20T04:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: Compress part of a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33672#M6604</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ksharp points the way. (happy new year to Ksharp)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A dictionary or conversion table could list common misspellings and the correct form you prefer.&amp;nbsp; The columns would be&lt;/P&gt;&lt;P&gt;This $30 &lt;/P&gt;&lt;P&gt;Should_be $30&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you would load into an array like CORRECTIONS below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;Proc SQL noprint ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; Select nobs into :nobs_dict from dictionary.tables where libname ='DICTLIB' and memname = 'DICTIONARY';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;Data corrected ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; Array corrections(&amp;amp;nobs_dict,2) $30 _temporary_ ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; If _n_=1 then do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; do _i_=1 to &amp;amp;nobs_dict ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set dictlib.dictionary point=_i_ ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; corrections(_i_,1)=this;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; corrections(_i_,2)=should_be;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; end ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; Set your.data ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;* now apply all dictionary entries to variable&amp;nbsp; target ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; do _i_=1 to &amp;amp;nobs_dict ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Target = tranwrd( target, trim(Corrections(_i_,1)), trim(corrections(_i_,2)));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;* BEWARE this code is untested;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Peter Crawford on a real computer because the iphone editor created some unhelpful extras&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Jan 2012 09:24:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33672#M6604</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2012-01-21T09:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: Compress part of a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33673#M6605</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Peter,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since the OP originally stated that the sequence of characters could be any combination of those characters, starting with and separated possibly by spaces, I think that a regex solution would still be advantageous.&amp;nbsp; Of course, it could always be combined with the development and utilization of a dictionary like you propose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shouldn't you finally break down and start learning how to capitalize on regular expressions?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 Jan 2012 00:13:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33673#M6605</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-01-22T00:13:13Z</dc:date>
    </item>
    <item>
      <title>Re: Compress part of a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33674#M6606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Below some tested code based on Ksharp's and Art's suggestions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What it does:&lt;BR /&gt;1 Data step 'SearchReplacePattern' to build a list of patterns based on target words. Eg. if the target word is UUNET then the data step will create a pattern which will match any combination of this string as defined. For UUNET the Regular Expression would be: \bU *U *N *E *T\b&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Data step 'have' to create some sample data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Data step 'want' compiles in the first iteration all patterns as needed for prxchange(). Then loops for every iteration of the data step through all compiled RegEx using prxchange() to replace all matching patterns with the desired target value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background-color: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; SearchReplacePattern(keep=_SearchReplacePattern);;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;length&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; TargetWord $&lt;/SPAN&gt;&lt;STRONG style="color: teal; background-color: white; font-family: 'Courier New';"&gt;40&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; _SearchReplacePattern &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: teal;"&gt;$160.&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; TargetWord&amp;nbsp; = &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple;"&gt;'UUNET'&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple;"&gt;'ABC'&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _SearchReplacePattern=prxchange(&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple;"&gt;'s/(\S{1}\B)/$1 */i'&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;,-&lt;/SPAN&gt;&lt;STRONG style="color: teal; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;,strip(TargetWord));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _SearchReplacePattern=cats(&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple;"&gt;'s/\b'&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;,_SearchReplacePattern,&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple;"&gt;'\b/'&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;,TargetWord,&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple;"&gt;'/i'&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;put&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; _SearchReplacePattern=;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background-color: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;length&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; String $ &lt;/SPAN&gt;&lt;STRONG style="color: teal; background-color: white; font-family: 'Courier New';"&gt;40&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp; String=&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple;"&gt;'word1 word2 uU net wordN'&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp; String=&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple;"&gt;'ab c word2 ab cword3 u u Net word a b c'&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background-color: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; want(drop=_:);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; _n_=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; _i=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; last;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; SearchReplacePattern nobs=last point=_i ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _PatternID=prxparse(_SearchReplacePattern);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;put&lt;/SPAN&gt; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple;"&gt;'Before: '&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; @&lt;/SPAN&gt;&lt;STRONG style="color: teal; background-color: white; font-family: 'Courier New';"&gt;9&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; String ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; _PatternID=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; last;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; String=prxchange(_PatternID,-&lt;/SPAN&gt;&lt;STRONG style="color: teal; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;,String);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;put&lt;/SPAN&gt; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple;"&gt;'After: '&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; @&lt;/SPAN&gt;&lt;STRONG style="color: teal; background-color: white; font-family: 'Courier New';"&gt;9&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; String /;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 Jan 2012 10:17:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-part-of-a-string/m-p/33674#M6606</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-01-22T10:17:42Z</dc:date>
    </item>
  </channel>
</rss>

