Compress function with closed parenthesis

Reply
Contributor
Posts: 58

Compress function with closed parenthesis


Hi,

I'm trying to apply compress function to a string with closed paranthesis inside.

basically I would remove each occurrence of closed paranthesis.

Which is the correct syntax?

I have done a lot of tries without success:

     %let varstring=MY STRING WITH ) CLOSED PARANTHESIS;

%let result            =%sysfunc(compress(&varstring, ' )');
%let result            =%sysfunc(compress(&typecodecomp, '(' )); -- it works, only for open parenthesis

%let result            =%sysfunc(compress(&typecodecomp, %str(%));

Could some one help me?

Many thanks.

Regards

Super User
Posts: 5,081

Re: Compress function with closed parenthesis

You're heading in the right direction.  Try:

%let result = %sysfunc(compress (%superq(typecodecomp), %str(%)) ));

You will still have two consecutive blanks after removing the parenthesis.  Good luck.

Should I be using VARSTRING instead of TYPECODECOMP?  Either way, the approach should work.

Contributor
Posts: 58

Re: Compress function with closed parenthesis

Many thanks Astounding, it works.

Anyway, who have developed Sas has a very big fantasy...SUPERQ is a very clear name for a function...very usefull

Ask a Question
Discussion stats
  • 2 replies
  • 378 views
  • 0 likes
  • 2 in conversation