In the data I list below, I'd like to replace all punctuation in variable TxtVar with a space. Furthermore, I'd like to have a macro that supports a parameter which specifies what characters qualify as punctuation. data have; infile datalines delimiter="\n"; input TxtVar $; datalines; This, has, commas\n And. This. Has. Periods\n This "is" harder\n How about some question marks ??\n ; My try so far is this macro: %macro ReplacePunct(datain, dataout, PunctChars); data &dataout ; set &datain ; TxtVar = TRANWRD(TxtVar, "&PunctChars.", " "); run; %mend; The macro call is: %ReplacePunct(have, want, %bquote(,) ); Obviously, this works as intended only if the PunctChars parameter only has a single character in it (in the example call above it has the comma). However, I would like to call it like this: %ReplacePunct(have, want, %bquote(,.;_@#/\?!'") ); So I gues there are two questions: 1. How do i handle the special characters? Double quotes (") or periods (.) always throws an error ? 2. How can I parse the contents of PunctChars parameter one by one ? (or any other method which would lead to replacing each occurence of every character with a space)
... View more