<?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 function in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Compress-function/m-p/565554#M11200</link>
    <description>&lt;P&gt;Because you included the code for space '20'x in your list. It is not in the lexicographical order&amp;nbsp; since you have it between '19'x and '1A'x instead of after '1F'x.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you just want to get a list of characters in order use the COLLATE() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;z=COMPRESS(x,collate(0,31));&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 12 Jun 2019 13:51:51 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-06-12T13:51:51Z</dc:date>
    <item>
      <title>Compress function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Compress-function/m-p/565470#M11177</link>
      <description>&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;Hello&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;I am trying to run below code&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;data new1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;length x $50.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;x='Sorslev Stole As New';&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;z=COMPRESS(x,'000102030405060708090A0B0C0D0E0F10111213141516171819201A1B1C1D1E1F'X)&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;When I see the output it looks like&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;x=Sorslev Stole As New&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;z=SorslevStoleAsNew&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;My question is why the spaces are removed in output variable Z&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;what does the compress remove the spaces when we have not mentioned&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 06:39:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Compress-function/m-p/565470#M11177</guid>
      <dc:creator>shubham1</dc:creator>
      <dc:date>2019-06-12T06:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: Compress function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Compress-function/m-p/565472#M11178</link>
      <description>&lt;P&gt;please try the below code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe you are trying to compress the numbers in the string then used 'ka' keep alphabets option and the ' ' will avoid the compressing of space.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new1;
length x $50.;
x='Sorslev Stole As New';
z=COMPRESS(x,' ','ka')
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jun 2019 06:55:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Compress-function/m-p/565472#M11178</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-06-12T06:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: Compress function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Compress-function/m-p/565479#M11179</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12151"&gt;@Jagadishkatam&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know i can use this&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But My question is what does&amp;nbsp; this line&amp;nbsp;&lt;SPAN&gt;00102030405060708090A0B0C0D0E0F10111213141516171819201A1B1C1D1E1F'X do in compress function&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;COMPRESS(x,'000102030405060708090A0B0C0D0E0F10111213141516171819201A1B1C1D1E1F'X)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 07:20:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Compress-function/m-p/565479#M11179</guid>
      <dc:creator>shubham1</dc:creator>
      <dc:date>2019-06-12T07:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: Compress function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Compress-function/m-p/565482#M11180</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/127952"&gt;@shubham1&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That expression ('000102...1F'X) is a character constant expressed in hexadecimal notation. It contains 66 hexadecimal digits (0-9,A-F), hence represents 33 (=66/2) characters: the characters with (decimal) ASCII codes 0, 1, 2, ..., 24, 25, &lt;STRONG&gt;32&lt;/STRONG&gt;, 26, 27, 28, 29, 30, 31. Most of these are non-printable characters, not available on the keyboard, which is why using hexadecimal notation makes sense. ASCII code 32 (hex 20) is the space character, so it &lt;EM&gt;is&lt;/EM&gt; among the characters to be deleted by the COMPRESS function, which explains the result in variable Z.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: Here is another example using the hexadecimal representations '41'x and '42'x of 'A' and 'B' (and again '20'x for the space ' '):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
c='PALM BEACH';
d=compress(c,'4142'x); /* equivalent: d=compress(c,'AB'); */
put d=;
e=compress(c,'414220'x);   /* equiv.: e=compress(c,'AB '); */
put e=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;d=PLM ECH
e=PLMECH&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jun 2019 08:12:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Compress-function/m-p/565482#M11180</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-06-12T08:12:13Z</dc:date>
    </item>
    <item>
      <title>Re: Compress function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Compress-function/m-p/565493#M11182</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are correct .But I have a question&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am doing a migration project .This code when running on mainframe SAS host it is not removing spaces there&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But&amp;nbsp; when I am running same code in windows it is removing spaces as you explained&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what is the reason for this&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 09:51:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Compress-function/m-p/565493#M11182</guid>
      <dc:creator>shubham1</dc:creator>
      <dc:date>2019-06-12T09:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: Compress function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Compress-function/m-p/565495#M11183</link>
      <description>&lt;P&gt;The mainframe uses &lt;A href="https://en.wikipedia.org/wiki/EBCDIC" target="_blank" rel="noopener"&gt;EBCDIC&lt;/A&gt; encoding, not ASCII (which is used under Windows). According to the table in the linked Wikipedia article the EBCDIC code of the space character is (hex) 40 as opposed to 20 in ASCII. So, on the mainframe you need to compress '40'x to remove blanks, not '20'x.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 10:04:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Compress-function/m-p/565495#M11183</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-06-12T10:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: Compress function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Compress-function/m-p/565550#M11199</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The mainframe uses &lt;A href="https://en.wikipedia.org/wiki/EBCDIC" target="_blank" rel="noopener"&gt;EBCDIC&lt;/A&gt; encoding, not ASCII (which is used under Windows). According to the table in the linked Wikipedia article the EBCDIC code of the space character is (hex) 40 as opposed to 20 in ASCII. So, on the mainframe you need to compress '40'x to remove blanks, not '20'x.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Right, Except that I believe SAS stores character data in ASCII in the dataset even on the Mainframe. (It has been about 25 years since I used SAS on IBM Mainframe.)&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 13:35:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Compress-function/m-p/565550#M11199</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-12T13:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: Compress function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Compress-function/m-p/565554#M11200</link>
      <description>&lt;P&gt;Because you included the code for space '20'x in your list. It is not in the lexicographical order&amp;nbsp; since you have it between '19'x and '1A'x instead of after '1F'x.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you just want to get a list of characters in order use the COLLATE() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;z=COMPRESS(x,collate(0,31));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jun 2019 13:51:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Compress-function/m-p/565554#M11200</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-12T13:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: Compress function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Compress-function/m-p/565622#M11220</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Right, Except that I believe SAS stores character data in ASCII in the dataset even on the Mainframe. (It has been about 25 years since I used SAS on IBM Mainframe.)&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Interesting, thanks for chiming in. I hoped the encoding difference would explain the OP's observation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have never used SAS on mainframes. My only encounters with EBCDIC data were data exchanges with customers involving awkward tape cartridges, about 20 years ago.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 17:00:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Compress-function/m-p/565622#M11220</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-06-12T17:00:35Z</dc:date>
    </item>
  </channel>
</rss>

