<?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 Reg:Compress Special Characters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reg-Compress-Special-Characters/m-p/12928#M1463</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another option is to use a regular expression.&amp;nbsp; The PERL function PRXCHANGE will do the job here, the code below will remove all non-word characters and the underscore.&amp;nbsp; The syntax takes a bit of getting used to, however there are plenty of online documents to help, including this useful tip sheet. &lt;A href="http://support.sas.com/rnd/base/datastep/perl_regexp/regexp-tip-sheet.pdf"&gt;http://support.sas.com/rnd/base/datastep/perl_regexp/regexp-tip-sheet.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;length old new $20;&lt;/P&gt;&lt;P&gt;old="-Bç_+¦lær“Y+-+-I ";&lt;/P&gt;&lt;P&gt;new=prxchange('s/[\W_]//o', -1, old);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 24 Feb 2012 12:26:58 GMT</pubDate>
    <dc:creator>Keith</dc:creator>
    <dc:date>2012-02-24T12:26:58Z</dc:date>
    <item>
      <title>Reg:Compress Special Characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reg-Compress-Special-Characters/m-p/12926#M1461</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp; i am having sepecial characters like this ╥Bç_┐▌lær“Y╓╤╙╥I&amp;nbsp; how can i compress them ,i am may get these kind of special characters in the future i can use the compress function and do it is there any way to compress all this kind of special characters like this for the unknown special characters like this. New=compress(old,'╥Bç_┐▌lær“Y╓╤╙╥I');&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Feb 2012 07:25:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reg-Compress-Special-Characters/m-p/12926#M1461</guid>
      <dc:creator>R_Win</dc:creator>
      <dc:date>2012-02-24T07:25:11Z</dc:date>
    </item>
    <item>
      <title>Reg:Compress Special Characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reg-Compress-Special-Characters/m-p/12927#M1462</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;compress has the third argument 'k' which can keep all the character you want.&lt;/P&gt;&lt;P&gt;For example: I only want keep character B &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data want;
 set sashelp.class;
 want=compress(name,'B','k');
 keep want;
run;


&lt;/PRE&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, 24 Feb 2012 07:45:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reg-Compress-Special-Characters/m-p/12927#M1462</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-02-24T07:45:21Z</dc:date>
    </item>
    <item>
      <title>Reg:Compress Special Characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reg-Compress-Special-Characters/m-p/12928#M1463</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another option is to use a regular expression.&amp;nbsp; The PERL function PRXCHANGE will do the job here, the code below will remove all non-word characters and the underscore.&amp;nbsp; The syntax takes a bit of getting used to, however there are plenty of online documents to help, including this useful tip sheet. &lt;A href="http://support.sas.com/rnd/base/datastep/perl_regexp/regexp-tip-sheet.pdf"&gt;http://support.sas.com/rnd/base/datastep/perl_regexp/regexp-tip-sheet.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;length old new $20;&lt;/P&gt;&lt;P&gt;old="-Bç_+¦lær“Y+-+-I ";&lt;/P&gt;&lt;P&gt;new=prxchange('s/[\W_]//o', -1, old);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Feb 2012 12:26:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reg-Compress-Special-Characters/m-p/12928#M1463</guid>
      <dc:creator>Keith</dc:creator>
      <dc:date>2012-02-24T12:26:58Z</dc:date>
    </item>
    <item>
      <title>Reg:Compress Special Characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reg-Compress-Special-Characters/m-p/12929#M1464</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;compress(name,,'kad')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;k - keep&lt;/P&gt;&lt;P&gt;a - letters&lt;/P&gt;&lt;P&gt;d - digits&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is equivalent to Keith's regular expression (s/[\W_]//o).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;\W finds the inverse of \w (letters, digits, and underscores) and then he choose to then also exclude underscores.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you do not want to remove underscores use 'kn' instead of a and d or change the regular expression to s/\W//o&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Feb 2012 23:25:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reg-Compress-Special-Characters/m-p/12929#M1464</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2012-02-24T23:25:37Z</dc:date>
    </item>
    <item>
      <title>Reg:Compress Special Characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reg-Compress-Special-Characters/m-p/12930#M1465</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Although, if you are going to use the k(eep) operator, you may also want to include s (for spaces and tabs) and p for punctuation marks (like commas and periods).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Feb 2012 23:36:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reg-Compress-Special-Characters/m-p/12930#M1465</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-24T23:36:24Z</dc:date>
    </item>
    <item>
      <title>Reg:Compress Special Characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reg-Compress-Special-Characters/m-p/12931#M1466</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi @FriedEegg,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did think of that Compress solution first of all (as it appears to be the simplest), however I discovered it doesn't strip out the foreign letters (e.g. ç or æ), whereas Prxchange does.&amp;nbsp; I guess there are subtle differences in the underlying code for these functions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So it looks like it depends on whether these letters are wanted or not as to which solution is the best to use.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Keith&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Feb 2012 08:46:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reg-Compress-Special-Characters/m-p/12931#M1466</guid>
      <dc:creator>Keith</dc:creator>
      <dc:date>2012-02-27T08:46:19Z</dc:date>
    </item>
    <item>
      <title>Reg:Compress Special Characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reg-Compress-Special-Characters/m-p/12932#M1467</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Compress can be limited to just English characters.&amp;nbsp; Take a look at: &lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212246.htm"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212246.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Feb 2012 13:37:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reg-Compress-Special-Characters/m-p/12932#M1467</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-27T13:37:24Z</dc:date>
    </item>
    <item>
      <title>Reg:Compress Special Characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reg-Compress-Special-Characters/m-p/12933#M1468</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@art297&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for that, sadly I'm still using 9.1. &lt;/P&gt;&lt;P&gt;If I put compress(old,,"kad") it keeps the foreign letters, yet if I put compress(old,,"kfd") it removes them!&amp;nbsp; The only difference between the 2 should be that "f" includes the underscore.&amp;nbsp; Looks like a bug in 9.1&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Feb 2012 14:28:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reg-Compress-Special-Characters/m-p/12933#M1468</guid>
      <dc:creator>Keith</dc:creator>
      <dc:date>2012-02-27T14:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: Reg:Compress Special Characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reg-Compress-Special-Characters/m-p/12934#M1469</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is it at least 9.1.3?&amp;nbsp; The modifiers weren't even added until then.&amp;nbsp; However, if you are on 9.1.3, then you could just specify exactly which characters you want to keep in the second field (which is currently only ,, ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regardless, is sounds like you already have an acceptable solution.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Feb 2012 14:38:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reg-Compress-Special-Characters/m-p/12934#M1469</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-27T14:38:09Z</dc:date>
    </item>
  </channel>
</rss>

