<?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: Compress, but whole word (not just the characters) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Compress-but-whole-word-not-just-the-characters/m-p/84642#M256886</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another approach, using Prx functions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data cars;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input make:$10. model&amp;amp;$20.; &lt;/P&gt;&lt;P&gt;&amp;nbsp; model = transtrn(model,strip(make),strip(' '));&lt;/P&gt;&lt;P&gt;&amp;nbsp; model_prx=prxchange(cats('s/',make,'//io'),-1,model);&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards; &lt;/P&gt;&lt;P&gt;VOLVO LR55VL&lt;/P&gt;&lt;P&gt;VOLVO VOLVO-LR55VL&lt;/P&gt;&lt;P&gt;VOLVO LR55VOLVO&lt;/P&gt;&lt;P&gt;VOLVO LR55 VOLVO&lt;/P&gt;&lt;P&gt;VOLVO VOLVO LR55&lt;/P&gt;&lt;P&gt;VOLVO VOLVO/LR55&lt;/P&gt;&lt;P&gt;;;;;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 18 Nov 2013 18:51:00 GMT</pubDate>
    <dc:creator>Haikuo</dc:creator>
    <dc:date>2013-11-18T18:51:00Z</dc:date>
    <item>
      <title>Compress, but whole word (not just the characters)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-but-whole-word-not-just-the-characters/m-p/84633#M256877</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 have two columns. One containing a vehicle make and the other a vehicle model. For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Column1&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; Column2&lt;/P&gt;&lt;P&gt;VOLVO&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; LR55VL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In some instances (from poor validation at data entry most probably), Column2 often contains the value from Column1 within the string. Example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Column1&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; Column2&lt;/P&gt;&lt;P&gt;VOLVO&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; VOLVO - LR55VL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was hoping to use the COMPRESS function like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COMPRESS(Column2, Column1) but that looks at the individual characters in column1 and compresses them ALL out of Column2 resulting in&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Column1&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; Column2&lt;/P&gt;&lt;P&gt;VOLVO&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; - R55&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I do something similar to compress but force it to contstrain the compression with the entire string in column1?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this example, i was hoping to achieve and output of&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Column1&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; Column2&lt;/P&gt;&lt;P&gt;VOLVO&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; - LR55VL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jan 2013 10:16:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-but-whole-word-not-just-the-characters/m-p/84633#M256877</guid>
      <dc:creator>ChrisElias</dc:creator>
      <dc:date>2013-01-24T10:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: Compress, but whole word (not just the characters)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-but-whole-word-not-just-the-characters/m-p/84634#M256878</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Chris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Considering that the column model has model value associated with the '-' to make, then you can follow the below code to get the desired result. Please let me know if this works for you&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input make : $10. model :$20.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if upcase(make)=upcase(scan(model,1,'-')) then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; new_model=scan(model,2,'-');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else new_model=model;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;VOLVO&amp;nbsp; LR55VL&lt;/P&gt;&lt;P&gt;VOLVO&amp;nbsp; VOLVO-LR55VL&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jagadish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jan 2013 10:33:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-but-whole-word-not-just-the-characters/m-p/84634#M256878</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2013-01-24T10:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: Compress, but whole word (not just the characters)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-but-whole-word-not-just-the-characters/m-p/84635#M256879</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;By using the scan, length and substring functions, you can romove your word from anywhere in the other column.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jan 2013 11:05:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-but-whole-word-not-just-the-characters/m-p/84635#M256879</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-01-24T11:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: Compress, but whole word (not just the characters)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-but-whole-word-not-just-the-characters/m-p/84636#M256880</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for such a quick response. Wasn't aware of the scan function and that would work for the example i provided. However i should have probably provided a little more of an example to show the range of the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In that, the make is not always followed by a "-". There isn't really any consistency as to where the make name could appear in the model field. Another example could be&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LR55VOLVO&lt;/P&gt;&lt;P&gt;LR55 VOLVO&lt;/P&gt;&lt;P&gt;VOLVO LR55&lt;/P&gt;&lt;P&gt;VOLVO/LR55&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This list isn't exhastive as some of the names are input by humans by free text&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So i'm guessing i need to put a CONTAINS element in here. In logic would be something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Assess if string in column2 CONTAINS string in column1 and provide the start postition of where the string in column1 is in column2. Then delete the following LEN(column1) from that start position.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does that make sense?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jan 2013 11:07:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-but-whole-word-not-just-the-characters/m-p/84636#M256880</guid>
      <dc:creator>ChrisElias</dc:creator>
      <dc:date>2013-01-24T11:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: Compress, but whole word (not just the characters)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-but-whole-word-not-just-the-characters/m-p/84637#M256881</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;CONTAINS are only valid in where clauses, but you could use findw (not scan - sorry). &lt;/P&gt;&lt;P&gt;The rest sounds good... &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jan 2013 11:16:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-but-whole-word-not-just-the-characters/m-p/84637#M256881</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-01-24T11:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: Compress, but whole word (not just the characters)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-but-whole-word-not-just-the-characters/m-p/84638#M256882</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; cars;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; make:&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;$10.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; model&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;$20.&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; model = transtrn(model,strip(make),strip(&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;' '&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;));&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;cards&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffc0;"&gt;VOLVO LR55VL&lt;BR /&gt;VOLVO VOLVO-LR55VL&lt;BR /&gt;VOLVO LR55VOLVO&lt;BR /&gt;VOLVO LR55 VOLVO&lt;BR /&gt;VOLVO VOLVO LR55&lt;BR /&gt;VOLVO VOLVO/LR55&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;;;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jan 2013 11:44:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-but-whole-word-not-just-the-characters/m-p/84638#M256882</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-01-24T11:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: Compress, but whole word (not just the characters)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-but-whole-word-not-just-the-characters/m-p/84639#M256883</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks All for your help this morning.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The transtrn function and data_null_ worked perfectly!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jan 2013 11:56:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-but-whole-word-not-just-the-characters/m-p/84639#M256883</guid>
      <dc:creator>ChrisElias</dc:creator>
      <dc:date>2013-01-24T11:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: Compress, but whole word (not just the characters)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-but-whole-word-not-just-the-characters/m-p/84640#M256884</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So, to be clear, it is not possible to use compress() to remove a word/phrase/string? It will also remove the component parts (e.g., letters) entirely?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Nov 2013 15:50:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-but-whole-word-not-just-the-characters/m-p/84640#M256884</guid>
      <dc:creator>kbk</dc:creator>
      <dc:date>2013-11-18T15:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: Compress, but whole word (not just the characters)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-but-whole-word-not-just-the-characters/m-p/84641#M256885</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Correct. Compress() is letter based, not string based.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Nov 2013 18:49:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-but-whole-word-not-just-the-characters/m-p/84641#M256885</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-11-18T18:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: Compress, but whole word (not just the characters)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-but-whole-word-not-just-the-characters/m-p/84642#M256886</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another approach, using Prx functions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data cars;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input make:$10. model&amp;amp;$20.; &lt;/P&gt;&lt;P&gt;&amp;nbsp; model = transtrn(model,strip(make),strip(' '));&lt;/P&gt;&lt;P&gt;&amp;nbsp; model_prx=prxchange(cats('s/',make,'//io'),-1,model);&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards; &lt;/P&gt;&lt;P&gt;VOLVO LR55VL&lt;/P&gt;&lt;P&gt;VOLVO VOLVO-LR55VL&lt;/P&gt;&lt;P&gt;VOLVO LR55VOLVO&lt;/P&gt;&lt;P&gt;VOLVO LR55 VOLVO&lt;/P&gt;&lt;P&gt;VOLVO VOLVO LR55&lt;/P&gt;&lt;P&gt;VOLVO VOLVO/LR55&lt;/P&gt;&lt;P&gt;;;;;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Nov 2013 18:51:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-but-whole-word-not-just-the-characters/m-p/84642#M256886</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-11-18T18:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: Compress, but whole word (not just the characters)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-but-whole-word-not-just-the-characters/m-p/84643#M256887</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;But, as you asked if "it was not possible", you have opened up a can of worms.&amp;nbsp; If the word(s) are comprised of specific characters, and those characters don't exist anywhere else in the string, then it is definitely possible.&amp;nbsp; e.g., using compress(string,'a') will definitely remove the "word" from strings like:&lt;/P&gt;&lt;P&gt;This is a nice evening&lt;/P&gt;&lt;P&gt;Is it a boy or girl?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Nov 2013 19:46:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-but-whole-word-not-just-the-characters/m-p/84643#M256887</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-11-18T19:46:07Z</dc:date>
    </item>
  </channel>
</rss>

