<?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 function not working in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/COMPRESS-function-not-working/m-p/265107#M52077</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;any ideas why compress is not getting rid of the space in the middle?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;CREATE TABLE xxx AS&lt;BR /&gt;SELECT &lt;BR /&gt;&amp;nbsp;A AS CommDesc&lt;BR /&gt;,COMPRESS('0802&amp;nbsp;12','') AS CN &lt;BR /&gt;from yyy;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Wed, 20 Apr 2016 14:25:10 GMT</pubDate>
    <dc:creator>metallon</dc:creator>
    <dc:date>2016-04-20T14:25:10Z</dc:date>
    <item>
      <title>COMPRESS function not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COMPRESS-function-not-working/m-p/265107#M52077</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;any ideas why compress is not getting rid of the space in the middle?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;CREATE TABLE xxx AS&lt;BR /&gt;SELECT &lt;BR /&gt;&amp;nbsp;A AS CommDesc&lt;BR /&gt;,COMPRESS('0802&amp;nbsp;12','') AS CN &lt;BR /&gt;from yyy;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2016 14:25:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COMPRESS-function-not-working/m-p/265107#M52077</guid>
      <dc:creator>metallon</dc:creator>
      <dc:date>2016-04-20T14:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: COMPRESS function not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COMPRESS-function-not-working/m-p/265110#M52079</link>
      <description>&lt;P&gt;need to tell it to remove spaces, Try this.&amp;nbsp; Also you should use quit, not run to end a proc SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
CREATE TABLE xxx AS
	SELECT
 		A AS CommDesc
		,COMPRESS('0802 12',' ') AS CN
		;
Quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Apr 2016 14:38:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COMPRESS-function-not-working/m-p/265110#M52079</guid>
      <dc:creator>dsbihill</dc:creator>
      <dc:date>2016-04-20T14:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: COMPRESS function not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COMPRESS-function-not-working/m-p/265112#M52081</link>
      <description>&lt;P&gt;proc sql;&lt;BR /&gt;CREATE TABLE xxx AS&lt;BR /&gt;SELECT&lt;BR /&gt;&amp;nbsp;A AS CommDesc&lt;BR /&gt;,COMPRESS('0802 12',,'s') AS CN&lt;BR /&gt;from yyy;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2016 14:36:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COMPRESS-function-not-working/m-p/265112#M52081</guid>
      <dc:creator>Loko</dc:creator>
      <dc:date>2016-04-20T14:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: COMPRESS function not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COMPRESS-function-not-working/m-p/265324#M52165</link>
      <description>Hi dsbihill,&lt;BR /&gt;Thanks for the hint. But that did not do the trick.&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/33792"&gt;@Loko&lt;/a&gt;, thanks for the example. That worked in this particular case but in no other &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;CREATE TABLE xxxx AS&lt;BR /&gt;SELECT &lt;BR /&gt;,COMPRESS('0709&amp;nbsp;30&amp;nbsp;00',,'s') AS CNA /*does not work*/&lt;BR /&gt;,COMPRESS('ex&amp;nbsp;1211&amp;nbsp;90&amp;nbsp;86',,'s') AS CNB /*does not work*/&lt;BR /&gt;,COMPRESS('0802&amp;nbsp;11',,'s') AS CNC /*does not work*/&lt;BR /&gt;,COMPRESS('0802 12',,'s') AS CND /*works*/&lt;BR /&gt;from yyyy;&lt;BR /&gt;quit;</description>
      <pubDate>Thu, 21 Apr 2016 06:34:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COMPRESS-function-not-working/m-p/265324#M52165</guid>
      <dc:creator>metallon</dc:creator>
      <dc:date>2016-04-21T06:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: COMPRESS function not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COMPRESS-function-not-working/m-p/265334#M52168</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have run the code you have provided and it works even for the examples you said "does not work" .&lt;/P&gt;&lt;P&gt;Are you sure it is a space there when you run the code in sas and not another character ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 07:30:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COMPRESS-function-not-working/m-p/265334#M52168</guid>
      <dc:creator>Loko</dc:creator>
      <dc:date>2016-04-21T07:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: COMPRESS function not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COMPRESS-function-not-working/m-p/265339#M52169</link>
      <description>odd. I go to a colleague now and check it at his PC.&lt;BR /&gt;its a space, see for yourself:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;CREATE TABLE xxxx AS&lt;BR /&gt;SELECT &lt;BR /&gt;COMPRESS('0709&amp;nbsp;30&amp;nbsp;00',,'s') AS CNA /*not working*/&lt;BR /&gt;,COMPRESS('ex&amp;nbsp;1211&amp;nbsp;90&amp;nbsp;86',,'s') AS CNB /*not working*/&lt;BR /&gt;,COMPRESS('0802&amp;nbsp;11',,'s') AS CNC /*not working*/&lt;BR /&gt;,COMPRESS('0802 12',,'s') AS CND  /*works*/&lt;BR /&gt;,compress('ex&amp;nbsp;1211&amp;nbsp;90&amp;nbsp;86',,'s') AS CNE&lt;BR /&gt;from sashelp.class;&lt;BR /&gt;quit;</description>
      <pubDate>Thu, 21 Apr 2016 07:50:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COMPRESS-function-not-working/m-p/265339#M52169</guid>
      <dc:creator>metallon</dc:creator>
      <dc:date>2016-04-21T07:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: COMPRESS function not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COMPRESS-function-not-working/m-p/265340#M52170</link>
      <description>&lt;P&gt;yes, strange. Maybe experts on the forum have an explanation for it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;anyway within the sas compress help function it is clearly stated the behaviour of S and there is also an example for it:&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212246.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212246.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 07:55:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COMPRESS-function-not-working/m-p/265340#M52170</guid>
      <dc:creator>Loko</dc:creator>
      <dc:date>2016-04-21T07:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: COMPRESS function not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COMPRESS-function-not-working/m-p/265366#M52179</link>
      <description>&lt;P&gt;Still not working.&lt;BR /&gt;Its a character variable, length 21. I importet the data from a .xls&lt;BR /&gt;the attached screen print shows the data.&lt;BR /&gt;if I copy and paste it I can detect the spaces/blanks.&lt;BR /&gt;and If I go over the data set with a proc sql and compress its not working.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;proc import&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datafile= '....' dbms=xls&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out=yyyyy&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; replace; *overwrites an existing SAS data set.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getnames=no;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datarow=2; &lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;CREATE TABLE xxxx AS&lt;BR /&gt;SELECT &lt;BR /&gt;compress(B,,'s') AS A /*not working*/&lt;BR /&gt;from yyyyy;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;/*further test*/&lt;BR /&gt;proc sql;&lt;BR /&gt;CREATE TABLE xxxx AS&lt;BR /&gt;SELECT &amp;nbsp;&lt;BR /&gt;compress('0802&amp;nbsp;12',,'s') AS A /*not working*/&lt;BR /&gt;,compress('0806&amp;nbsp;20',,'s') AS B /*not working*/&lt;BR /&gt;,compress('2008 11 10',,'s') AS C /*works*/&lt;BR /&gt;from sashelp.class;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 09:23:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COMPRESS-function-not-working/m-p/265366#M52179</guid>
      <dc:creator>metallon</dc:creator>
      <dc:date>2016-04-21T09:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: COMPRESS function not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COMPRESS-function-not-working/m-p/265490#M52218</link>
      <description>&lt;P&gt;Have you tried&lt;/P&gt;
&lt;P&gt;compress('0802&amp;nbsp;12',' ','s') AS A&lt;/P&gt;
&lt;P&gt;where the second arguement is a single space?&lt;/P&gt;
&lt;P&gt;The S operator ADDS characters to the string of the second argument. But I suspect if there is not a string there nothing is added.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 18:10:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COMPRESS-function-not-working/m-p/265490#M52218</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-04-21T18:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: COMPRESS function not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COMPRESS-function-not-working/m-p/265499#M52222</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect that what you have is non-printable characters and not space.&lt;/P&gt;
&lt;P&gt;If the values are only Numeric try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;FONT color="#000080"&gt;proc sql;&lt;/FONT&gt;
CREATE TABLE xxx AS
SELECT 
 A AS CommDesc
,COMPRESS('0802 12','N') AS CN 
from yyy;
&lt;FONT color="#003366"&gt;quit;&lt;/FONT&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 18:28:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COMPRESS-function-not-working/m-p/265499#M52222</guid>
      <dc:creator>BrunoSilva</dc:creator>
      <dc:date>2016-04-21T18:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: COMPRESS function not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/COMPRESS-function-not-working/m-p/265535#M52237</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21847"&gt;@metallon﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get a definitive answer as to what kind of "blank" character you have in the strings in question, you should print (a few of) them with $HEX&lt;EM&gt;w&lt;/EM&gt;. format (with &lt;EM&gt;w &amp;gt;&lt;/EM&gt;= twice the length of the string).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
s1='123 456';
c1=compress(s1,,'s');
s2='123&amp;nbsp;456'; /* The "blank" here is a protected blank, 'A0'x! */
c2=compress(s2,,'s');
put (s: c:) (=);
put (s: c:) (= $hex14.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result (colors added):&lt;/P&gt;
&lt;PRE&gt;s1=123 456 s2=123&amp;nbsp;456 c1=123456 c2=123&amp;nbsp;456
s1=313233&lt;FONT color="#339966"&gt;20&lt;/FONT&gt;343536 s2=313233&lt;FONT color="#FF0000"&gt;A0&lt;/FONT&gt;343536 c1=31323334353620 c2=313233&lt;FONT color="#FF0000"&gt;A0&lt;/FONT&gt;343536&lt;/PRE&gt;
&lt;P&gt;(Surprisingly,&amp;nbsp;my SAS 9.4&amp;nbsp;(TS1M2) does not compress the protected blank, contrary to what is stated in the documentation.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can use the appropriate&amp;nbsp;arguments of the COMPRESS function to get rid of these blank characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15181"&gt;@BrunoSilva﻿&lt;/a&gt;'s suggestion to use a &lt;EM&gt;positive&lt;/EM&gt; list of characters to keep (such as "only digits") can be helpful in this situation. You have to include the k ("keep") modifier, though:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token function"&gt;compress&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'0802 12'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'kn'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 21:50:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/COMPRESS-function-not-working/m-p/265535#M52237</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-04-21T21:50:55Z</dc:date>
    </item>
  </channel>
</rss>

