<?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: Is it possible to use Tranwrd for more than 1 possible group of words? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-use-Tranwrd-for-more-than-1-possible-group-of/m-p/520224#M141034</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;. i am not good in regular expression. If i plan to add more possible values to be excluded, is this how it should be done?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to add these into the regular expression:&lt;/P&gt;&lt;P&gt;1) (a)-&amp;lt;space&amp;gt;&lt;/P&gt;&lt;P&gt;2) #&lt;/P&gt;&lt;P&gt;3) &amp;lt;space&amp;gt;&lt;/P&gt;&lt;P&gt;4) PP&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;

x='CB 123 (a) 456';
y=prxchange('s/\babc\b|\bCB\b|\(a\) |\#\|\bPP|\ \|\(a\)//i',-1,x);
put x= / y=;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Instead of using this method, can i also use this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let y1=CB ;

%let y2=PP;

%let y3=(a);

%do i=1 to 3

y=tranwrd(x,&amp;amp;&amp;amp;y&amp;amp;i..,'');

%end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It may sound very "beginner" and too MANUAL, but this is the easiest way that i can think of. I have also come across a do loop from other threads but i just couldnt make it work.&lt;/P&gt;&lt;P&gt;The code as below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;

   set have;

   n_name = o_name;

   length word $27 ;

   do word='JR', 'SR', 'III', 'IV', 'DECD' ;

      n_name = tranwrd(' '||n_name, ' '||strip(word)||' ', ' ');

  end;

   n_name = compbl(n_name);

   drop word ;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I replace JR with PP and SR with CB&amp;lt;space&amp;gt;&lt;/P&gt;&lt;P&gt;I assume n_name is my original variables&lt;/P&gt;&lt;P&gt;I think it didnt replace or i hit error, i cannot remember and I am currently out from my workstation. Can i tweak it to cater for my criteria?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Dec 2018 02:48:45 GMT</pubDate>
    <dc:creator>imdickson</dc:creator>
    <dc:date>2018-12-11T02:48:45Z</dc:date>
    <item>
      <title>Is it possible to use Tranwrd for more than 1 possible group of words?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-use-Tranwrd-for-more-than-1-possible-group-of/m-p/519745#M140832</link>
      <description>&lt;P&gt;Hi, I am planning to replace a list of words with blank. For example, I would like to replace 'ABC' with '' and '(a)' with '' and many more.&lt;/P&gt;&lt;P&gt;However, i couldnt find any answer to it. Is there a special function that allows me to use for replacing a list of possible values with blank?&lt;/P&gt;</description>
      <pubDate>Sun, 09 Dec 2018 11:27:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-use-Tranwrd-for-more-than-1-possible-group-of/m-p/519745#M140832</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2018-12-09T11:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to use Tranwrd for more than 1 possible group of words?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-use-Tranwrd-for-more-than-1-possible-group-of/m-p/519749#M140833</link>
      <description>&lt;P&gt;Could you please provide sample data and expected output to get the answer&lt;/P&gt;</description>
      <pubDate>Sun, 09 Dec 2018 12:16:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-use-Tranwrd-for-more-than-1-possible-group-of/m-p/519749#M140833</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2018-12-09T12:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to use Tranwrd for more than 1 possible group of words?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-use-Tranwrd-for-more-than-1-possible-group-of/m-p/519750#M140834</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
x='I am planning to replace a abclist of words with blank. abc';
y=prxchange('s/\b(abc|words|with)\b//i',-1,x);
put x= / y=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 09 Dec 2018 12:19:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-use-Tranwrd-for-more-than-1-possible-group-of/m-p/519750#M140834</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-12-09T12:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to use Tranwrd for more than 1 possible group of words?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-use-Tranwrd-for-more-than-1-possible-group-of/m-p/519817#M140870</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;thanks for the code. I have a scenario where it is possible that the variable contains value such as '(a)' without the single quote and maybe '-' without single quote.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to do this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;

x='CB 123 (a) 456';
y=prxchange('s/\b(abc|CB |(a))\b//i',-1,x);
put x= / y=;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, it doesnt work as in the open and close bracket wont be eliminated. Further, how do i make sure the code eliminate dash as well?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 02:22:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-use-Tranwrd-for-more-than-1-possible-group-of/m-p/519817#M140870</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2018-12-10T02:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to use Tranwrd for more than 1 possible group of words?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-use-Tranwrd-for-more-than-1-possible-group-of/m-p/519910#M140914</link>
      <description>&lt;P&gt;OK. try this one .&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;

x='CB 123 (a) 456';
y=prxchange('s/\babc\b|\bCB\b|\(a\)//i',-1,x);
put x= / y=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Dec 2018 12:00:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-use-Tranwrd-for-more-than-1-possible-group-of/m-p/519910#M140914</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-12-10T12:00:34Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to use Tranwrd for more than 1 possible group of words?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-use-Tranwrd-for-more-than-1-possible-group-of/m-p/520224#M141034</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;. i am not good in regular expression. If i plan to add more possible values to be excluded, is this how it should be done?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to add these into the regular expression:&lt;/P&gt;&lt;P&gt;1) (a)-&amp;lt;space&amp;gt;&lt;/P&gt;&lt;P&gt;2) #&lt;/P&gt;&lt;P&gt;3) &amp;lt;space&amp;gt;&lt;/P&gt;&lt;P&gt;4) PP&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;

x='CB 123 (a) 456';
y=prxchange('s/\babc\b|\bCB\b|\(a\) |\#\|\bPP|\ \|\(a\)//i',-1,x);
put x= / y=;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Instead of using this method, can i also use this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let y1=CB ;

%let y2=PP;

%let y3=(a);

%do i=1 to 3

y=tranwrd(x,&amp;amp;&amp;amp;y&amp;amp;i..,'');

%end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It may sound very "beginner" and too MANUAL, but this is the easiest way that i can think of. I have also come across a do loop from other threads but i just couldnt make it work.&lt;/P&gt;&lt;P&gt;The code as below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;

   set have;

   n_name = o_name;

   length word $27 ;

   do word='JR', 'SR', 'III', 'IV', 'DECD' ;

      n_name = tranwrd(' '||n_name, ' '||strip(word)||' ', ' ');

  end;

   n_name = compbl(n_name);

   drop word ;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I replace JR with PP and SR with CB&amp;lt;space&amp;gt;&lt;/P&gt;&lt;P&gt;I assume n_name is my original variables&lt;/P&gt;&lt;P&gt;I think it didnt replace or i hit error, i cannot remember and I am currently out from my workstation. Can i tweak it to cater for my criteria?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 02:48:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-use-Tranwrd-for-more-than-1-possible-group-of/m-p/520224#M141034</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2018-12-11T02:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to use Tranwrd for more than 1 possible group of words?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-use-Tranwrd-for-more-than-1-possible-group-of/m-p/520347#M141075</link>
      <description>&lt;P&gt;Can you give an example ? and you want change a WORD or just a string ?&lt;/P&gt;
&lt;P&gt;If you want change a WORD, you need add '\b' as I did before.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;

x='CB 123 (a) 456 #';
y=prxchange('s/PP|\(a\)|#|\s+//i',-1,x);
put x= / y=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Dec 2018 13:20:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-use-Tranwrd-for-more-than-1-possible-group-of/m-p/520347#M141075</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-12-11T13:20:13Z</dc:date>
    </item>
  </channel>
</rss>

