<?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: Inserting a single quote via PRXCHANGE? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Inserting-a-single-quote-via-PRXCHANGE/m-p/342060#M63305</link>
    <description>&lt;P&gt;You are going to get unwanted results unless you modify the regular expression to look for a word boundary too&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input text_field $10.;
cards;
Expression
Tools
;
run;

data want;
set have;
new_text_field=prxchange('s/([A-Z]\w+)(?=s)/$1''/',-1,text_field);
foo_text_field=prxchange('s/([A-Z]\w+)(?=s\b)/$1''/',-1,text_field);
put (text_field new_text_field foo_text_field) (/=);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;text_field=Expression
new_text_field=Expres'sion
foo_text_field=Expression

text_field=Tools
new_text_field=Tool's
foo_text_field=Tool's
&lt;/PRE&gt;</description>
    <pubDate>Fri, 17 Mar 2017 17:32:57 GMT</pubDate>
    <dc:creator>FriedEgg</dc:creator>
    <dc:date>2017-03-17T17:32:57Z</dc:date>
    <item>
      <title>Inserting a single quote via PRXCHANGE?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Inserting-a-single-quote-via-PRXCHANGE/m-p/342053#M63303</link>
      <description>&lt;P&gt;Hi all - I would like to use a single quote in the PRXCHANGE function as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;new_text_field&amp;nbsp;= PRXCHANGE('s/([A-Z]\w+)(?=s)/&lt;FONT color="#FF0000"&gt;$1\'&lt;/FONT&gt;/',-1,text_field);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the above returns an error. It doesn't like that single quote in the &lt;FONT color="#FF0000"&gt;pink&lt;/FONT&gt; section. I know these are a pain to read but this would ideally scan text for words that end in 's' and replace them so that they end in 's basically making them possessive. This works if I use a dash instead of a single quote.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea how to make it accept the single quote?&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 17:08:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Inserting-a-single-quote-via-PRXCHANGE/m-p/342053#M63303</guid>
      <dc:creator>bluth_family</dc:creator>
      <dc:date>2017-03-17T17:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting a single quote via PRXCHANGE?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Inserting-a-single-quote-via-PRXCHANGE/m-p/342058#M63304</link>
      <description>&lt;P&gt;Use double quotes to surround a string with a single quote inside&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;new_text_field = PRXCHANGE("s/([A-Z]\w+)(?=s)/$1'/", -1, text_field);&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 17:30:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Inserting-a-single-quote-via-PRXCHANGE/m-p/342058#M63304</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-03-17T17:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting a single quote via PRXCHANGE?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Inserting-a-single-quote-via-PRXCHANGE/m-p/342060#M63305</link>
      <description>&lt;P&gt;You are going to get unwanted results unless you modify the regular expression to look for a word boundary too&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input text_field $10.;
cards;
Expression
Tools
;
run;

data want;
set have;
new_text_field=prxchange('s/([A-Z]\w+)(?=s)/$1''/',-1,text_field);
foo_text_field=prxchange('s/([A-Z]\w+)(?=s\b)/$1''/',-1,text_field);
put (text_field new_text_field foo_text_field) (/=);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;text_field=Expression
new_text_field=Expres'sion
foo_text_field=Expression

text_field=Tools
new_text_field=Tool's
foo_text_field=Tool's
&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Mar 2017 17:32:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Inserting-a-single-quote-via-PRXCHANGE/m-p/342060#M63305</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2017-03-17T17:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting a single quote via PRXCHANGE?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Inserting-a-single-quote-via-PRXCHANGE/m-p/342064#M63306</link>
      <description>&lt;P&gt;Thank you to both!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And yes I have not yet tackled the word boundary issue but I am aware of it. Good advice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 17:38:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Inserting-a-single-quote-via-PRXCHANGE/m-p/342064#M63306</guid>
      <dc:creator>bluth_family</dc:creator>
      <dc:date>2017-03-17T17:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting a single quote via PRXCHANGE?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Inserting-a-single-quote-via-PRXCHANGE/m-p/342065#M63307</link>
      <description>Well I meant to mark this as the solution. Now I can't undo it. I am a dork.</description>
      <pubDate>Fri, 17 Mar 2017 17:40:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Inserting-a-single-quote-via-PRXCHANGE/m-p/342065#M63307</guid>
      <dc:creator>bluth_family</dc:creator>
      <dc:date>2017-03-17T17:40:11Z</dc:date>
    </item>
  </channel>
</rss>

