<?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 unbalanced parentheses in a string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680443#M205642</link>
    <description>&lt;P&gt;I have added some test cases in order to deal with &lt;STRONG&gt;nested parenthesis&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;Next code is tested and seems to do the job as requested:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/***
  https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680071
***/

%let maxl=30; /* max string length */
data have;
   length string $&amp;amp;maxl;  
   input string $&amp;amp;maxl..;	 
cards;
How (are (you (my friend)))
(This is (a) test)
(This is a test
This is a test)
(This (is) a test
(This is) a test)
)This (is a test
This (is) (a) test)
; run;


data want;
 set have;
  *IF _N_ in (1 5 8);
     /* level used as indicator to insert couple of parenthesis */
     array opn {&amp;amp;maxl} op1-op&amp;amp;maxl;  /* position of '(' */
	 array cls {&amp;amp;maxl} cl1-cl&amp;amp;maxl;  /* position of ')' */
	 _org = string;
 
/*   status:                */
/*      0=initial,          */
/*      1=open,             */
/*      2="(" follows "(",  */
/*      3=")" follows "(",  */
/*      9=exit              */

	 status = 0; level=0; delta=0;
	 do until (status=9);
	    link scan;
	 end;
	 /* insert parenthesis back to string */
	 do j=1 to length(string);
	    if opn(j) ^= . and cls(j) ^= . then do;;
	    substr(string,opn(j),1) = '(';   
	    substr(string,cls(j),1) = ')';   
	 end; end;
	 keep _org string;
RETURN;
SCAN:
     lstr = length(string); 
	 do j =1 to lstr;
	    if status=9 then leave;
	    ch = substr(string,j,1);
	    if ch = '(' then link opn; else
	    if ch = ')' then link cls; 
    	if j ge length(string) then link end_scan;
	 end;
	 
RETURN;
OPN:
     level+1;
     opn(level)=j;
     if status = 0 then status=1; else
     if status = 1 then status=2; 
     delta=delta+1; 
     ch = ' ';
RETURN;
CLS:
  putlog 'CLS: ' ch= j= level= status= delta=;
	if status = 0 then substr(string,j,1) = ' '; else
	if status=1 then do; * ) follows ( ;
	   cls(level) = j;
	   substr(string,opn(level),1) = ' '; /* remove ( */
	   substr(string,j,1) = ' ';          /* remove ) */
	   status=0;
	end; else
	if status=2 then do; * ) follows ( ( ;
	   cls(level) = j; 
	   substr(string,opn(level),1) = ' '; /* remove ( */
	   substr(string,j,1) = ' ';          /* remove ) */
	   if delta &amp;gt; 0 then do; delta=delta-1; level=level-1; end;
	   if delta=0 then status=1;
	end; else
	if status=3 then do;  * ) follows ) ;
	   level = level - delta;
	   if level=1 then status=2;
	end;
RETURN;
END_SCAN:
    do j=1 to lstr;
       if opn(j) ne . and cls(j) = . then substr(string,opn(j),1) = ' ';
       if cls(j) ne . and opn(j) = . then substr(string,cls(j),1) = ' ';
    end;
    status = 9;
RETURN;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 31 Aug 2020 14:31:32 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2020-08-31T14:31:32Z</dc:date>
    <item>
      <title>Remove unbalanced parentheses in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680071#M205450</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;Is there a quick way to remove unbalanced parentheses /brackets&amp;nbsp; from a string ?&lt;/P&gt;
&lt;P&gt;For example in the table below can i get the column "want" as result with just the matched parentheses retained ?&lt;/P&gt;
&lt;TABLE width="318"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="173"&gt;&lt;STRONG&gt;HAVE&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="145"&gt;&lt;STRONG&gt;WANT&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;(This is a test)&lt;/TD&gt;
&lt;TD&gt;(This is a test)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;(This is a test&lt;/TD&gt;
&lt;TD&gt;This is a test&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;This is a test)&lt;/TD&gt;
&lt;TD&gt;This is a test&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;(This (is) a test&lt;/TD&gt;
&lt;TD&gt;This (is) a test&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;(This is) a test)&lt;/TD&gt;
&lt;TD&gt;(This is) a test&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;)This (is a test&lt;/TD&gt;
&lt;TD&gt;This is a test&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Fri, 28 Aug 2020 18:27:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680071#M205450</guid>
      <dc:creator>NN</dc:creator>
      <dc:date>2020-08-28T18:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: Remove unbalanced parentheses in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680097#M205462</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18128"&gt;@NN&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Is there a quick way to remove unbalanced parentheses /brackets&amp;nbsp; from a string ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Quick way? No.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You'd have to define a very clear and comprehensive set of rules and then program them up.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Aug 2020 20:15:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680097#M205462</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-08-28T20:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: Remove unbalanced parentheses in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680106#M205467</link>
      <description>&lt;P&gt;It is relatively easy to determine when a mismatch occurs. Consider:&lt;/P&gt;
&lt;PRE&gt;data junk;
   x = "(This is) a test)";
   left = countc(x,"(");
   right= countc(x,")");
run;&lt;/PRE&gt;
&lt;P&gt;If Left is not equal to right then there is a mismatch.&lt;/P&gt;
&lt;P&gt;But determining which level of parsing a value for&amp;nbsp; matches is a good piece of writing a programming language syntax parser. For just one example of what goes on:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.cs.iusb.edu/~dvrajito/teach/c311/c311_11_parser.html" target="_blank"&gt;https://www.cs.iusb.edu/~dvrajito/teach/c311/c311_11_parser.html&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "trivial" mismatch case of exactly one of the parentheses appearing is easy enough.&lt;/P&gt;
&lt;PRE&gt;data junk;
   x = "(This is a test";
   left = countc(x,"(");
   right= countc(x,")");
   if left ne right and max(left, right) = 1 then do;
      if left then y=compress(x,'(');
      else y=compress(x,')');
   end;
run;&lt;/PRE&gt;
&lt;P&gt;But as soon as you get into your other examples you start having to parse a value character by character keeping track of the positions and order of ( and ) characters and then after you have examined the whole value then start applying rules and likely from the "middle" of something outwards.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Aug 2020 20:41:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680106#M205467</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-08-28T20:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: Remove unbalanced parentheses in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680166#M205491</link>
      <description>&lt;P&gt;Next is a tested code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/***
  https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680071
  
  input - a string 
  target - remove unbalanced ()
  algorithm:
     scan the string 
	 keep positions of '(' followed by ')' and remove them
	 repeat until found:
	   - ( without ) and remove the (
	   - ) preceding (  and remove the )
	   - none found
	 insert couples of () back into thier positions
***/

%let maxl=30; /* max string length */
data have;
   length string $&amp;amp;maxl;  /* adapt to max length */
   input string $&amp;amp;maxl..;	 
cards;
(This is a test)
(This is a test
This is a test)
(This (is) a test
(This is) a test)
)This (is a test
This (is) (a) test)
; run;

data want;
 set have;
     /* use i as indicator to insert couple of parenthesis */
     array opn {&amp;amp;maxl} op1-op&amp;amp;maxl;  /* position of '(' */
	 array cls {&amp;amp;maxl} cl1-cl&amp;amp;maxl;  /* position of ')' */
	 
	 status = 0; /* 0=initial, 1=open found, 2=match found, 9=exit */
	 i=1;
	 do until (status=9);
	    link scan;
	 end;
	 /* insert parenthesis back to string */
	 if i&amp;gt;1 then do j=1 to i-1;
	    substr(string,opn(j),1) = '(';   
	    substr(string,cls(j),1) = ')';   
	 end;
	 keep string;
RETURN;
SCAN:
	 do j =1 to length(string);
	    ch = substr(string,j,1);
		if status = 0 and ch=')' then substr(string,j,1) = ' '; else
		if ch = '(' then do;
		   status=1; opn(i)=j;
		end;
		if status = 1 and ch = ')' then do;
		   status = 2; cls(i) = j;
		   substr(string,opn(i),1) = ' '; /* remove ( */
		   substr(string,j,1) = ' ';      /* remove ) */
		   i+1;
		 end;
		if j &amp;lt; length(string) then do;
		   if status=1 then substr(string,opn(i),1) = ' '; 
		   if status=2 then status = 0; 
		end; else status = 9;
	end;
RETURN;
RUN;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Aug 2020 13:57:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680166#M205491</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-08-29T13:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: Remove unbalanced parentheses in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680189#M205505</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18128"&gt;@NN&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Quick way? Yes, if (like in your examples) there are no &lt;EM&gt;nested pairs&lt;/EM&gt; of parentheses &lt;EM&gt;and&lt;/EM&gt; you can specify two characters which are not present in the strings to work with.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
string=translate(compress(prxchange("s/\(([^\(\)]*)\)/þ$1ÿ/",-1,string),"()"),"()","þÿ");
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The PRXCHANGE function replaces the parentheses in substrings of the form "(&lt;EM&gt;text without parentheses&lt;/EM&gt;)" by replacement characters (I chose &lt;FONT face="courier new,courier"&gt;'þ'='FE'x&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;'ÿ'='FF'x&lt;/FONT&gt;, but you may want to use others). The remaining, hence unmatched parentheses are removed by the COMPRESS function. Finally, the TRANSLATE function restores the replaced parentheses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If nested pairs of parentheses may occur in &lt;FONT face="courier new,courier"&gt;string&lt;/FONT&gt;, apply PRXCHANGE repetitively:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
do until(string=lag(string));
  string=prxchange("s/\(([^\(\)]*)\)/þ$1ÿ/",-1,string);
end;
string=translate(compress(string,"()"),"()","þÿ");
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Of course, this implies rules to decide, e.g., which of the three parentheses in your fourth and fifth example is regarded as unmatched.&lt;/P&gt;</description>
      <pubDate>Sat, 29 Aug 2020 10:04:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680189#M205505</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-08-29T10:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: Remove unbalanced parentheses in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680202#M205514</link>
      <description>&lt;PRE&gt;data have;
   input string $40.;	 
cards;
(This is a test)
(This is a test
This is a test)
(This (is) a test
(This is) a test)
)This (is a test
This (is) (a) test)
; run;

data want;
 set have;
 _string=translate(string,'  ','()');
 pid=prxparse('/\([^()]+\)/');
 s=1;e=length(string);
 call prxnext(pid,s,e,string,p,l);
 do while(p&amp;gt;0);
   substr(_string,p,1)='(';
   substr(_string,p+l-1,1)=')';
   call prxnext(pid,s,e,string,p,l);
 end;
keep string _string;
run;&lt;/PRE&gt;</description>
      <pubDate>Sat, 29 Aug 2020 13:53:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680202#M205514</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-08-29T13:53:11Z</dc:date>
    </item>
    <item>
      <title>Re: Remove unbalanced parentheses in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680443#M205642</link>
      <description>&lt;P&gt;I have added some test cases in order to deal with &lt;STRONG&gt;nested parenthesis&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;Next code is tested and seems to do the job as requested:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/***
  https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680071
***/

%let maxl=30; /* max string length */
data have;
   length string $&amp;amp;maxl;  
   input string $&amp;amp;maxl..;	 
cards;
How (are (you (my friend)))
(This is (a) test)
(This is a test
This is a test)
(This (is) a test
(This is) a test)
)This (is a test
This (is) (a) test)
; run;


data want;
 set have;
  *IF _N_ in (1 5 8);
     /* level used as indicator to insert couple of parenthesis */
     array opn {&amp;amp;maxl} op1-op&amp;amp;maxl;  /* position of '(' */
	 array cls {&amp;amp;maxl} cl1-cl&amp;amp;maxl;  /* position of ')' */
	 _org = string;
 
/*   status:                */
/*      0=initial,          */
/*      1=open,             */
/*      2="(" follows "(",  */
/*      3=")" follows "(",  */
/*      9=exit              */

	 status = 0; level=0; delta=0;
	 do until (status=9);
	    link scan;
	 end;
	 /* insert parenthesis back to string */
	 do j=1 to length(string);
	    if opn(j) ^= . and cls(j) ^= . then do;;
	    substr(string,opn(j),1) = '(';   
	    substr(string,cls(j),1) = ')';   
	 end; end;
	 keep _org string;
RETURN;
SCAN:
     lstr = length(string); 
	 do j =1 to lstr;
	    if status=9 then leave;
	    ch = substr(string,j,1);
	    if ch = '(' then link opn; else
	    if ch = ')' then link cls; 
    	if j ge length(string) then link end_scan;
	 end;
	 
RETURN;
OPN:
     level+1;
     opn(level)=j;
     if status = 0 then status=1; else
     if status = 1 then status=2; 
     delta=delta+1; 
     ch = ' ';
RETURN;
CLS:
  putlog 'CLS: ' ch= j= level= status= delta=;
	if status = 0 then substr(string,j,1) = ' '; else
	if status=1 then do; * ) follows ( ;
	   cls(level) = j;
	   substr(string,opn(level),1) = ' '; /* remove ( */
	   substr(string,j,1) = ' ';          /* remove ) */
	   status=0;
	end; else
	if status=2 then do; * ) follows ( ( ;
	   cls(level) = j; 
	   substr(string,opn(level),1) = ' '; /* remove ( */
	   substr(string,j,1) = ' ';          /* remove ) */
	   if delta &amp;gt; 0 then do; delta=delta-1; level=level-1; end;
	   if delta=0 then status=1;
	end; else
	if status=3 then do;  * ) follows ) ;
	   level = level - delta;
	   if level=1 then status=2;
	end;
RETURN;
END_SCAN:
    do j=1 to lstr;
       if opn(j) ne . and cls(j) = . then substr(string,opn(j),1) = ' ';
       if cls(j) ne . and opn(j) = . then substr(string,cls(j),1) = ' ';
    end;
    status = 9;
RETURN;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Aug 2020 14:31:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680443#M205642</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-08-31T14:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: Remove unbalanced parentheses in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680457#M205655</link>
      <description>Nice codes. However, it seems to not work for parent parenthesis with nested parenthesis. for example:&lt;BR /&gt;(This (is)) (a) test)</description>
      <pubDate>Mon, 31 Aug 2020 15:34:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680457#M205655</guid>
      <dc:creator>MINX</dc:creator>
      <dc:date>2020-08-31T15:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: Remove unbalanced parentheses in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680612#M205722</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/163484"&gt;@MINX&lt;/a&gt;&amp;nbsp;thank you for the challenge.&lt;/P&gt;
&lt;P&gt;I have added your example and some for and fixed the code.&lt;/P&gt;
&lt;P&gt;I left all my debugging statement for those who may be interested in it -&amp;nbsp;&lt;/P&gt;
&lt;P&gt;those lines start with&lt;EM&gt; /*DBG*/ putlog&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/***
  https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680071
***/

%let maxl=30; /* max string length */
data have;
   length string $&amp;amp;maxl;  
   input string $&amp;amp;maxl..;	 
cards;
How (are (you (my friend)))
(This (is)) (a) test) 
(This (is)) ((a) test 
(This (is)) ((a) test).)
(This is (a) test)
(This is a test
This is a test)
(This (is) a test
(This is) a test)
)This (is a test
This (is) (a) test)
; run;


data want;
 set have;
     /* level used as indicator to insert couple of parenthesis */
     array opn {&amp;amp;maxl} op1-op&amp;amp;maxl;  /* position of '(' */
	 array cls {&amp;amp;maxl} cl1-cl&amp;amp;maxl;  /* position of ')' */
	 _org = string; 
/*DBG*/ putlog _N_= string=;
 
/*   status:                */
/*      0=initial,          */
/*      1=open,             */
/*      2="(" follows "(",  */
/*      3=")" follows "(",  */
/*      9=exit              */

	 status = 0; level=0; delta=0;
	 max_level = 0;
	 do until (status=9);
	    link scan;
	 end;
	 /* insert parenthesis back to string */
	 do j=1 to length(string);
	    if opn(j) ^= . and cls(j) ^= . then do;;
	    substr(string,opn(j),1) = '(';   
	    substr(string,cls(j),1) = ')';   
	 end; end;
/*DBG*/ putlog _N_= string=;
	 keep _org string;
RETURN;
SCAN:
     lstr = length(string); 
/*DBG*/ putlog _N_= 'length(string)=' lstr;
	 do j =1 to lstr;
	    if status=9 then leave;
	    ch = substr(string,j,1);
	    if ch = '(' then link opn; else
	    if ch = ')' then link cls; 
    	if j ge length(string) then link end_scan;
	 end;
	 
RETURN;
OPN:
     level = max_level +1;
	 max_level = level;
     opn(level)=j;
     if status = 0 then status=1; else
     if status = 1 then status=2; 
     delta=delta+1; 
/*DBG*/ putlog j= ch= level= status= delta= op1= op2= op3= op4=;
     ch = ' ';
RETURN;
CLS:
/*DBG*/ putlog 'CLS: ' ch= j= level= status= delta= max_level=;
	if status = 0 then substr(string,j,1) = ' '; else
    if delta=0 then do; 
/*DBG*/ putlog 'CLS: 0';
       level = max_level+1;
       opn(level) = .; 
       cls(level) = j;  
       substr(string,j,1) = ' ';
       return; 
    end;
	if status=1 then do; * ) follows ( ;
	   cls(level) = j;
	   substr(string,opn(level),1) = ' '; /* remove ( */
	   substr(string,j,1) = ' ';          /* remove ) */
	   status=0;
	end; else
	if status=2 then do; * ) follows ( ( ;
	   cls(level) = j; 
	   substr(string,opn(level),1) = ' '; /* remove ( */
	   substr(string,j,1) = ' ';          /* remove ) */
	   if delta &amp;gt; 0 then do; delta=delta-1; level=level-1; end;
	   if delta=0 then status=1;
	end; else
	if status=3 then do;  * ) follows ) ;
	   level = level - delta;
	   if level=1 then status=2;
	end;
/*DBG*/ putlog 'CLS: ' ch= j= level= status= delta= /
         '&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; ' op1= op2= op3= op4= cl1= cl2= cl3= cl4= ;
RETURN;
END_SCAN:
    do j=1 to lstr;
       if opn(j) ne . and cls(j) = . then substr(string,opn(j),1) = ' ';
       if cls(j) ne . and opn(j) = . then substr(string,cls(j),1) = ' ';
    end;
    status = 9;
RETURN;
RUN;
	 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 05:26:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680612#M205722</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-09-01T05:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: Remove unbalanced parentheses in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680655#M205752</link>
      <description>Thank you Everyone for your amazing solutions.&lt;BR /&gt;Sorry for the delay in my reply.&lt;BR /&gt;&lt;BR /&gt;Most of these solutions work perfectly for my requirement. &lt;BR /&gt;But i shall be going ahead with FreelanceReinhards solution as i was looking a regex based compact solution.&lt;BR /&gt;&lt;BR /&gt;Thanks Again to all the Gurus.</description>
      <pubDate>Tue, 01 Sep 2020 10:08:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680655#M205752</guid>
      <dc:creator>NN</dc:creator>
      <dc:date>2020-09-01T10:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: Remove unbalanced parentheses in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680719#M205786</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18128"&gt;@NN&lt;/a&gt;&amp;nbsp;, though&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;'s logic is brilliant&lt;/P&gt;
&lt;P&gt;but the regex did not result, for my understanding, as&amp;nbsp; expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the log of running the code with minor modification, in order to display&lt;/P&gt;
&lt;P&gt;both the original value and the outcome value in the log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;73         data want_F;
 74          set have(firstobs=5);
 75              _org = string;
 76              string=translate(compress(prxchange("s/\(([^\(\)]*)\)/þ$1ÿ/",-1,string),"()"),"()","þÿ");
 77              putlog _N_= _org= / '        ' string=;
 78         run;
 
 _N_=1 _org=(This is (a) test)
         string=This is ()a(  test
 _N_=2 _org=(This is a test
         string=This is a test
 _N_=3 _org=This is a test)
         string=This is a test
 _N_=4 _org=(This (is) a test
         string=This ()is(  a test
 _N_=5 _org=(This is) a test)
         string=()This is(  a test
 _N_=6 _org=)This (is a test
         string=This is a test
 _N_=7 _org=This (is) (a) test)
         string=This ()is(  ()a(  test
 NOTE: There were 7 observations read from the data set WORK.HAVE.&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have coded&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;'s logic as a sas step and it is realy much shorter then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;mine previous solution. Next is my new code based on this logic:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let maxl=30; /* max string length */
data have;
   length string $&amp;amp;maxl;  
   input string $&amp;amp;maxl..;	 
cards;
How (are (you (my friend)))
(This (is)) (a) test) 
(This (is)) ((a) test 
(This (is)) ((a) test).)
(This is (a) test)
(This is a test
This is a test)
(This (is) a test
(This is) a test)
)This (is a test
This (is) (a) test)
; run;


data want;
 set have;
     _org = string;
	 do until (status=9);
	    link scan;
	 end;
	 string = translate(string,'  ()','()'||"FAFB"x);
     put _N_= _org= / '     ' string=;
RETURN;
SCAN:
    do i=1 to length(string);
       status = 9;
       if substr(string,i,1) = '(' then p = i;
       if substr(string,i,1) = ')' and p&amp;gt;0
          then do;
          substr(string,p,1) = 'FA'x;
          substr(string,i,1) = 'FB'x;
          p=0;
          status=0;
          leave;
       end;
    end;        
RETURN;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the outcome copied from the log is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt; _N_=1 _org=How (are (you (my friend)))
     string=How (are (you (my friend)))
 _N_=2 _org=(This (is)) (a) test)
     string=(This (is)) (a) test
 _N_=3 _org=(This (is)) ((a) test
     string=(This (is))  (a) test
 _N_=4 _org=(This (is)) ((a) test).)
     string=(This (is)) ((a) test).
 _N_=5 _org=(This is (a) test)
     string=(This is (a) test)
 _N_=6 _org=(This is a test
     string=This is a test
 _N_=7 _org=This is a test)
     string=This is a test
 _N_=8 _org=(This (is) a test
     string=This (is) a test
 _N_=9 _org=(This is) a test)
     string=(This is) a test
 _N_=10 _org=)This (is a test
     string=This  is a test
 _N_=11 _org=This (is) (a) test)
     string=This (is) (a) test
 NOTE: There were 11 observations read from the data set WORK.HAVE.&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 15:23:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680719#M205786</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-09-01T15:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: Remove unbalanced parentheses in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680802#M205839</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I had tested the second code he had shared with the loop and that seemed to work fine.&lt;/P&gt;
&lt;P&gt;I ran the same with the records you shared and below is the result. Is there something that i am missing here ?&lt;/P&gt;
&lt;PRE&gt;23         data want;
24         set have;
25         _org=string;
26         do until(string=lag(string));
27           string=prxchange("s/\(([^\(\)]*)\)/þ$1ÿ/",-1,string);
28         end;
29         string=translate(compress(string,"()"),"()","þÿ");
30         put _N_= _org= / '     ' string=;
31         run;

_N_=1 _org=How (are (you (my friend)))
     string=How (are (you (my friend)))
_N_=2 _org=(This (is)) (a) test)
     string=(This (is)) (a) test
_N_=3 _org=(This (is)) ((a) test
     string=(This (is)) (a) test
_N_=4 _org=(This (is)) ((a) test).)
     string=(This (is)) ((a) test).
_N_=5 _org=(This is (a) test)
     string=(This is (a) test)
_N_=6 _org=(This is a test
     string=This is a test
_N_=7 _org=This is a test)
     string=This is a test
_N_=8 _org=(This (is) a test
     string=This (is) a test
_N_=9 _org=(This is) a test)
     string=(This is) a test
_N_=10 _org=)This (is a test
     string=This is a test
_N_=11 _org=This (is) (a) test)
     string=This (is) (a) test
&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Sep 2020 19:17:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680802#M205839</guid>
      <dc:creator>NN</dc:creator>
      <dc:date>2020-09-01T19:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: Remove unbalanced parentheses in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680807#M205843</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for translating my regex solution into a data step using more elementary functions. I haven't checked the "translation," but it might be helpful for later readers who find regular expressions too cryptic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I &lt;EM&gt;have&lt;/EM&gt; checked the log you posted and I cannot replicate the results you obtained. Here is my log using the code copied from yours and also using your HAVE dataset (code):&lt;/P&gt;
&lt;PRE&gt;105  data want_F;
106  set have(firstobs=5);
107  _org = string;
108  string=translate(compress(prxchange("s/\(([^\(\)]*)\)/þ$1ÿ/",-1,string),"()"),"()","þÿ");
109  putlog _N_= _org= / '        ' string=;
110  run;

_N_=1 _org=(This is (a) test)
        string=This is (a) test
_N_=2 _org=(This is a test
        string=This is a test
_N_=3 _org=This is a test)
        string=This is a test
_N_=4 _org=(This (is) a test
        string=This (is) a test
_N_=5 _org=(This is) a test)
        string=(This is) a test
_N_=6 _org=)This (is a test
        string=This is a test
_N_=7 _org=This (is) (a) test)
        string=This (is) (a) test
NOTE: There were 7 observations read from the data set WORK.HAVE.&lt;/PRE&gt;
&lt;P&gt;Not sure how the strange results on your computer emerged. (Perhaps some sort of encoding issue?) To investigate it, I would store the intermediate results (i.e., of PRXCHANGE alone, then of COMPRESS) in separate variables. As mentioned earlier, the code version which also handles nested pairs of parentheses is that with the DO-UNTIL loop, but this is not the point here.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 20:00:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680807#M205843</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-09-01T20:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: Remove unbalanced parentheses in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680812#M205846</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18128"&gt;@NN&lt;/a&gt;, it is realy strange and may be it is a result of the environment differences.&lt;/P&gt;
&lt;P&gt;I have run the second code and got the same issue as before:&lt;/P&gt;
&lt;P&gt;The code and sample data -&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let maxl=30; /* max string length */
data have;
   length string $&amp;amp;maxl;  
   input string $&amp;amp;maxl..;	 
cards;
How (are (you (my friend)))
(This (is)) (a) test) 
(This (is)) ((a) test 
(This (is)) ((a) test).)
(This is (a) test)
(This is a test
This is a test)
(This (is) a test
(This is) a test)
)This (is a test
This (is) (a) test)
; run;
data want_F;
 set have;
     _org = string;
     do until(string=lag(string));
        string=prxchange("s/\(([^\(\)]*)\)/þ$1ÿ/",-1,string);
     end;
     string=translate(compress(string,"()"),"()","þÿ");
     putlog _N_= _org= / '        ' string=;
run;	 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the log with results -&lt;/P&gt;
&lt;PRE&gt;122        data want_F;
 123         set have;
 124             _org = string;
 125             do until(string=lag(string));
 126                string=prxchange("s/\(([^\(\)]*)\)/þ$1ÿ/",-1,string);
 127             end;
 128             string=translate(compress(string,"()"),"()","þÿ");
 129             putlog _N_= _org= / '        ' string=;
 130        run;
 
 _N_=1 _org=How (are (you (my friend)))
         string=How are ()you ()my friend( (
 _N_=2 _org=(This (is)) (a) test)
         string=()This ()is( (  ()a(  test
 _N_=3 _org=(This (is)) ((a) test
         string=()This ()is( (  ()a(  test
 _N_=4 _org=(This (is)) ((a) test).)
         string=()This ()is( (  ()()a(  test(
 _N_=5 _org=(This is (a) test)
         string=()This is ()a(  test(
 _N_=6 _org=(This is a test
         string=This is a test
 _N_=7 _org=This is a test)
         string=This is a test
 _N_=8 _org=(This (is) a test
         string=This ()is(  a test
 _N_=9 _org=(This is) a test)
         string=()This is(  a test
 _N_=10 _org=)This (is a test
         string=This is a test
 _N_=11 _org=This (is) (a) test)
         string=This ()is(  ()a(  test
 NOTE: There were 11 observations read from the data set WORK.HAVE.&lt;/PRE&gt;
&lt;P&gt;so, if it works fine at your environment, ignore the issue I have.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm using SAS UE with Oracle VM virtual box, windows 10.&lt;/P&gt;
&lt;P&gt;I have no explanation for the issue.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 20:18:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680812#M205846</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-09-01T20:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: Remove unbalanced parentheses in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680824#M205852</link>
      <description>&lt;P&gt;While&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;&lt;SPAN&gt;chosed&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;'þ'='FE'x&lt;/FONT&gt;&amp;nbsp;and&amp;nbsp;&lt;FONT face="courier new,courier"&gt;'ÿ'='FF'x&lt;/FONT&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&lt;STRONG&gt;,&lt;/STRONG&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;those characters behave differently&amp;nbsp;in my&amp;nbsp;&lt;/SPAN&gt;environment, that is UTF-8:&lt;/P&gt;
&lt;PRE&gt; 73         data a;
 74           x="þÿ";
 75           putlog x= $hex.;
 76         run;
 
 x=C3BEC3BF&lt;/PRE&gt;
&lt;P&gt;and this probably explains my issue.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 22:29:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680824#M205852</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-09-01T22:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: Remove unbalanced parentheses in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680896#M205896</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;I'm curious to know if you see the same symbols I see.&lt;/P&gt;
&lt;P&gt;The next picture is the screenshot of my last post - what graphic is shown for 'EF'x and 'FF'x -&lt;/P&gt;
&lt;P&gt;those tow characters which hold 2 bytes in your environment hold 4 bytes in UTF-8 environment:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EF-FF.JPG" style="width: 539px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/48861i1C1AE8ECBC5A583A/image-size/large?v=v2&amp;amp;px=999" role="button" title="EF-FF.JPG" alt="EF-FF.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Sep 2020 08:50:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680896#M205896</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-09-02T08:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: Remove unbalanced parentheses in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680900#M205897</link>
      <description>&lt;P&gt;If on Utf, i think you can try using "kcompress" instead of compress function and "ktranslate" instead of translate.&lt;/P&gt;
&lt;P&gt;that should work.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Sep 2020 09:39:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680900#M205897</guid>
      <dc:creator>NN</dc:creator>
      <dc:date>2020-09-02T09:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: Remove unbalanced parentheses in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680915#M205902</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18128"&gt;@NN&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;If on Utf, i think you can try using "kcompress" instead of compress function and "ktranslate" instead of translate.&lt;/P&gt;
&lt;P&gt;that should work.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You are right, I replaced the translate &amp;amp; compress to k-functions but at the same time&lt;/P&gt;
&lt;P&gt;I had to enlarge the length of the string and finally got the correct results.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Sep 2020 10:35:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680915#M205902</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-09-02T10:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: Remove unbalanced parentheses in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680936#M205912</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;I'm curious to know if you see the same symbols I see.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;: I see the same symbols, but with my Wlatin1 session encoding the PUTLOG statement, of course, writes &lt;FONT face="courier new,courier"&gt;x=FEFF&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My first idea for these temporary replacement characters were non-printable characters like '02'x (especially to avoid ASCII codes &amp;gt;127), but these are less convenient to use in PRXCHANGE and also caused other difficulties. That's why I resorted to 'FE'x and 'FF'x (but there may be better choices, also depending on the language of the text and expected characters in variable STRING).&lt;/P&gt;</description>
      <pubDate>Wed, 02 Sep 2020 11:58:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/680936#M205912</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-09-02T11:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: Remove unbalanced parentheses in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/681039#M205944</link>
      <description>&lt;P&gt;May I summit this chain from my point of view:&lt;/P&gt;
&lt;P&gt;1) While test was moved between different encoding environments (in this case from Latin1 to UTF-8)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;the hexadecimal representation of characters was changed in order to keep their visual appearance.&lt;/P&gt;
&lt;P&gt;2) The target of this post was an interesting challenge of programming for me and at the same time&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; a good experience to understand Perl expression (Regex) used with prxchange function and the&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; usage of k functions (ktranslate, kcompress) - both new for me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So thanks a lot to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;and to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18128"&gt;@NN&lt;/a&gt;&amp;nbsp;for your responses.&lt;/P&gt;
&lt;P&gt;I appreciate it very much. Have a nice day.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Sep 2020 15:45:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-unbalanced-parentheses-in-a-string/m-p/681039#M205944</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-09-02T15:45:18Z</dc:date>
    </item>
  </channel>
</rss>

