<?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 Keeping both &amp;quot; and ' in compress in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752316#M236952</link>
    <description>&lt;P&gt;I have a character variable that contains alphabets, numbers, some symbols, and both ' and " and also some strange characters (characters that are not on any keyboard). I want to create a new variable with only the characters I want. Because I am using " before and after my list, I cannot write " to keep it in my observations for the variable var. How may I include "?&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
new_var=compress(var,"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890$%.-':|&amp;amp;[]{}*!@#()!/+,");
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 06 Jul 2021 14:01:21 GMT</pubDate>
    <dc:creator>Emma_at_SAS</dc:creator>
    <dc:date>2021-07-06T14:01:21Z</dc:date>
    <item>
      <title>Keeping both " and ' in compress</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752316#M236952</link>
      <description>&lt;P&gt;I have a character variable that contains alphabets, numbers, some symbols, and both ' and " and also some strange characters (characters that are not on any keyboard). I want to create a new variable with only the characters I want. Because I am using " before and after my list, I cannot write " to keep it in my observations for the variable var. How may I include "?&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
new_var=compress(var,"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890$%.-':|&amp;amp;[]{}*!@#()!/+,");
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Jul 2021 14:01:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752316#M236952</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-07-06T14:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping both " and ' in compress</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752321#M236955</link>
      <description>&lt;P&gt;To include the character used to quote a string literal just double it up in the string content. Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;word = 'Don''t';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So if you are using " on the outside to include it as one of the characters just add "" to the list.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;compress(var,"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890$%.-""':|&amp;amp;[]{}*!@#()!/+,")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 14:26:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752321#M236955</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-06T14:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping both " and ' in compress</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752324#M236957</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/84351"&gt;@Emma_at_SAS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It might be easier to use the "k" modifier. It reverses the compress, so only the specifies characters are kept indtead of dropped.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Drop all printable and non-printable chars except "ABC":&amp;nbsp; &lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;compress(str,'ABC','k');&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Drop&amp;nbsp;all printable and non-printable chars except digits, english chars and underscore. There are no characters specified, but the mentioned chars are added with the 'n' modifier. More examples in the online documentation:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;compress(str,,'nk');&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 14:36:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752324#M236957</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2021-07-06T14:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping both " and ' in compress</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752328#M236958</link>
      <description>&lt;P&gt;How about just-&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;compress(var,,'p');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Jul 2021 14:43:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752328#M236958</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2021-07-06T14:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping both " and ' in compress</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752336#M236960</link>
      <description>Thank you, novinosrin. What does this combination do? Thanks!</description>
      <pubDate>Tue, 06 Jul 2021 15:13:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752336#M236960</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-07-06T15:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping both " and ' in compress</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752337#M236961</link>
      <description>&lt;P&gt;Thank you,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12887"&gt;@ErikLund_Jensen&lt;/a&gt;.&amp;nbsp;A combination of your suggestions solved my problem&lt;/P&gt;
&lt;P&gt;I used the double "" and,"k" modifier and that gives me exactly what I want.&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 15:16:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752337#M236961</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-07-06T15:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping both " and ' in compress</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752347#M236967</link>
      <description>&lt;P&gt;May someone please help me to mark this conversation as solved? I am not sure because it was solved based on two suggestions.&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 16:10:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752347#M236967</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-07-06T16:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping both " and ' in compress</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752384#M236993</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/84351"&gt;@Emma_at_SAS&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0jshdjy2z9zdzn1h7k90u99lyq6.htm" target="_blank" rel="noopener"&gt;documentation&lt;/A&gt;&amp;nbsp;of the &lt;FONT face="courier new,courier"&gt;scan()&lt;/FONT&gt; function, when the &lt;STRONG&gt;&lt;EM&gt;modifier&lt;/EM&gt; &lt;/STRONG&gt;argument is set to "p", as in&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;'s post, punctuation is added to the list of characters that are to be removed from the text:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;TABLE class="xisDoc-listValueDescription"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="xisDoc-value"&gt;p or P&lt;/TD&gt;
&lt;TD class="xisDoc-valueDescription"&gt;adds punctuation marks to the list of characters.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 18:48:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752384#M236993</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2021-07-06T18:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping both " and ' in compress</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752545#M237080</link>
      <description>new_var=compress(var, , 'kg');</description>
      <pubDate>Wed, 07 Jul 2021 12:51:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752545#M237080</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-07-07T12:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping both " and ' in compress</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752615#M237113</link>
      <description>&lt;P class="lia-align-left"&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input var$ ;
datalines;
oÔÇÖ\[}s 
dsd_'"sf 
;
run;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P class="lia-align-left"&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="branch lia-align-left"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.TEST" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt; &lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;Obs&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;var&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="l data"&gt;oÔÇÖ\[}s&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;2&lt;/TH&gt;
&lt;TD class="l data"&gt;dsd_'"sf&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set test;
new_var=compress(var,"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890$%.-'"":|&amp;amp;[]{}*!@#()!/+, ",'kg');
run;

proc print data=want; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;TABLE class="systitleandfootercontainer" border="0" summary="Page Layout" width="100%" frame="void" rules="none" cellspacing="1" cellpadding="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="c systemtitle"&gt;The SAS System&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;BR /&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt; &lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;Obs&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;var&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;new_var&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="l data"&gt;oÔÇÖ\[}s&lt;/TD&gt;
&lt;TD class="l data"&gt;oÔÇÖ\[}s&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;2&lt;/TH&gt;
&lt;TD class="l data"&gt;dsd_'"sf&lt;/TD&gt;
&lt;TD class="l data"&gt;dsd_'"sf&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;for your suggestion. I already have a solution but I thought this might be easier to just remove the "graphic characters". Beacuse I want to keep everything except the translation of emojis that appear in my SAS dataset. May you please help me with an example? Thanks&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P class="lia-align-left"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 17:04:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752615#M237113</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-07-07T17:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping both " and ' in compress</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752851#M237181</link>
      <description>You could list all the characters you want keep as you did with 'k'.&lt;BR /&gt;&lt;BR /&gt;new_var=compress(var,"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890$%.-'"":|&amp;amp;[]{}*!@#()!/+, ",    'k' &lt;BR /&gt; );</description>
      <pubDate>Thu, 08 Jul 2021 12:02:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752851#M237181</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-07-08T12:02:55Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping both " and ' in compress</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752886#M237192</link>
      <description>Thank you, Ksharp. This is what I was using the 'k' modifier. I was hoping to be able to use the 'g' modifier to only exclude the graphic characters. Maybe at some point, I learn to work efficiently with the modifiers. Thanks!</description>
      <pubDate>Thu, 08 Jul 2021 14:49:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/752886#M237192</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-07-08T14:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping both " and ' in compress</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/753112#M237322</link>
      <description>exclude 'g'  --&amp;gt; could use 'g' instead of 'k'.&lt;BR /&gt;new_var=compress(var,"ABC "  ,'g');</description>
      <pubDate>Fri, 09 Jul 2021 11:31:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-both-quot-and-in-compress/m-p/753112#M237322</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-07-09T11:31:40Z</dc:date>
    </item>
  </channel>
</rss>

