<?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: Removing text in brackets from value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Removing-text-in-brackets-from-value/m-p/778787#M247940</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/160861"&gt;@kalbo&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If those "brackets" are only balanced parentheses, try a recursive approach like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input var1 $80.;
datalines;
text(where=(upcase(num)="A"))
text text (in=a)
text (in=a) text2 (where=(upcase(strip(var1))))
;

data want(drop=_:);
set have;
do until(var1=_var1);
  _var1=var1;
  var1=compbl(prxchange('s/\([^()]*\)//',-1,var1));
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 05 Nov 2021 14:47:26 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2021-11-05T14:47:26Z</dc:date>
    <item>
      <title>Removing text in brackets from value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-text-in-brackets-from-value/m-p/778756#M247930</link>
      <description>&lt;P&gt;Hi I would like to remove brackets plus any text inside, for example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;have:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;VAR1&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;text(where=(upcase(num)="A"))&lt;/P&gt;
&lt;P&gt;text text (in=a)&lt;/P&gt;
&lt;P&gt;text (in=a) text2 (where=(upcase(strip(var1))))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;want:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;VAR1&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;text&lt;/P&gt;
&lt;P&gt;text text&lt;/P&gt;
&lt;P&gt;text text2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks for your help&lt;/P&gt;</description>
      <pubDate>Fri, 05 Nov 2021 13:25:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-text-in-brackets-from-value/m-p/778756#M247930</guid>
      <dc:creator>kalbo</dc:creator>
      <dc:date>2021-11-05T13:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: Removing text in brackets from value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-text-in-brackets-from-value/m-p/778787#M247940</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/160861"&gt;@kalbo&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If those "brackets" are only balanced parentheses, try a recursive approach like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input var1 $80.;
datalines;
text(where=(upcase(num)="A"))
text text (in=a)
text (in=a) text2 (where=(upcase(strip(var1))))
;

data want(drop=_:);
set have;
do until(var1=_var1);
  _var1=var1;
  var1=compbl(prxchange('s/\([^()]*\)//',-1,var1));
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Nov 2021 14:47:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-text-in-brackets-from-value/m-p/778787#M247940</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-11-05T14:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: Removing text in brackets from value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-text-in-brackets-from-value/m-p/778914#M248009</link>
      <description>&lt;P&gt;Just for fun&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input var1 $ 1 - 50;
datalines;
text(where=(upcase(num)="A"))                   
text text (in=a)                                
text (in=a) text2 (where=(upcase(strip(var1)))) 
;

data want;

   set have;
   
   do i = 1 to length(var1);
   
      if char(var1, i) = "(" then do;
         c = 0;
         do j = i to length(var1);
            if char(var1, j) = "(" then c ++ 1;
            if char(var1, j) = ")" then c +- 1;
            substr(var1, j, 1) = "";
            if c = 0 then leave;
         end;
      end;
   end;
   
   var1 = compbl(var1);

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 06 Nov 2021 08:46:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-text-in-brackets-from-value/m-p/778914#M248009</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-11-06T08:46:01Z</dc:date>
    </item>
  </channel>
</rss>

