Hi @Shmuel ,
I had tested the second code he had shared with the loop and that seemed to work fine.
I ran the same with the records you shared and below is the result. Is there something that i am missing here ?
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
... View more