<?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: Remove test when it hits a 'Title' in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Remove-test-when-it-hits-a-Title/m-p/603585#M174878</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input order_message $ 1-46;
datalines;
Congratulations on your order Mr Ben Griggs
Congratulations on your order Mr Trevor Terry
Congratulations on your order Miss Kate Jones
Congratulations on your order Dr Jon Berry
;

data want;
    set have;
    newVar=prxchange('s/(Mr|Miss|Mrs|Dr|Sir|Ms|Prof).*//', -1, order_message);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;order_message                                  NewVar
Congratulations on your order Mr Ben Griggs    Congratulations on your order
Congratulations on your order Mr Trevor Terry  Congratulations on your order
Congratulations on your order Miss Kate Jones  Congratulations on your order
Congratulations on your order Dr Jon Berry     Congratulations on your order&lt;/PRE&gt;</description>
    <pubDate>Tue, 12 Nov 2019 14:17:50 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2019-11-12T14:17:50Z</dc:date>
    <item>
      <title>Remove test when it hits a 'Title'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-test-when-it-hits-a-Title/m-p/603584#M174877</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a variable (order_message) whereby some outputs are personalised to a an individual (example below)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Congratulations on your order Mr Ben Griggs&lt;/P&gt;
&lt;P&gt;Congratulations on your order Mr Trevor Terry&lt;/P&gt;
&lt;P&gt;Congratulations on your order Miss Kate Jones&lt;/P&gt;
&lt;P&gt;Congratulations on your order Dr Jon Berry&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I write some code to say if at the end of an order_message we have a title that consists of either of the following Mr, Miss, Mrs, Dr, Sir, Ms, Prof. then delete so all we see is 'Congratulations on your order'?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2019 14:12:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-test-when-it-hits-a-Title/m-p/603584#M174877</guid>
      <dc:creator>KC_16</dc:creator>
      <dc:date>2019-11-12T14:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: Remove test when it hits a 'Title'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-test-when-it-hits-a-Title/m-p/603585#M174878</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input order_message $ 1-46;
datalines;
Congratulations on your order Mr Ben Griggs
Congratulations on your order Mr Trevor Terry
Congratulations on your order Miss Kate Jones
Congratulations on your order Dr Jon Berry
;

data want;
    set have;
    newVar=prxchange('s/(Mr|Miss|Mrs|Dr|Sir|Ms|Prof).*//', -1, order_message);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;order_message                                  NewVar
Congratulations on your order Mr Ben Griggs    Congratulations on your order
Congratulations on your order Mr Trevor Terry  Congratulations on your order
Congratulations on your order Miss Kate Jones  Congratulations on your order
Congratulations on your order Dr Jon Berry     Congratulations on your order&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Nov 2019 14:17:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-test-when-it-hits-a-Title/m-p/603585#M174878</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-11-12T14:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: Remove test when it hits a 'Title'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-test-when-it-hits-a-Title/m-p/603833#M174983</link>
      <description>&lt;P&gt;I think you should add \b.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want;
    set have;
    newVar=prxchange('s/\b(Mr|Miss|Mrs|Dr|Sir|Ms|Prof)\b.*//i', -1, order_message);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Otherwise ,something like&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"Congratulations on your ordMr Mr Ben Griggs"&lt;/P&gt;
&lt;P&gt;would get you wrong result .&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 12:33:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-test-when-it-hits-a-Title/m-p/603833#M174983</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-11-13T12:33:59Z</dc:date>
    </item>
  </channel>
</rss>

