It seems that TRANSLATE would be a good function to use. However when using %SYSFUNC with this function, the parameters are not surrounded with quotes. How do you indicate a blank should be used as replacement?
views:
346answers:
3
+2
A:
The %str( ) (with a blank between the parens) can be used to indicate a blank for this parameter. Also be careful with TRANSLATE...the 2nd param is the replacement char...however in TRANWRD it is reversed.
%macro test ;
%let original= translate_this_var ;
%let replaceWithThis= %str( ) ;
%let findThis= _ ;
%let translated= %sysfunc(translate(&original, &replaceWithThis, &findThis)) ;
%put Original: &original ***** TRANSLATEd: &translated ;
%mend ;
%test;
%macro test2 ;
%let original= translate_this_var ;
%let replaceWithThis= %str( ) ;
%let findThis= _ ;
%let tranwrded= %sysfunc(tranwrd(&original, &findThis, &replaceWithThis)) ;
%put Original: &original ***** TRANWRDed: &tranwrded ;
%mend ;
%test2
CarolinaJay65
2009-02-06 17:20:23
+1
A:
you can use perl reg ex instead, like:
%put ***%sysfunc(prxchange(s/x/ /, -1, abxcdxxf))***;
/* on log
***ab cd f***
*/
Chang Chung
2009-02-22 04:39:50