7

I want to change any instances of a period in a macro variable to underscore. What am I doing wrong?

%let pow=0.1;
%let x = %sysfunc(tranwrd(&pow,".","_"));
%put x=&x;

Output:

x=0.1

itzy
  • 11,275
  • 15
  • 63
  • 96

1 Answers1

11

No quotes in a %sysfunc, unless you mean the quote character. (Translate would have hidden the issue, at least, but TRANWRD was looking at &pow and trying to find "." and failing.)

%let pow=0.1;
%let x = %sysfunc(tranwrd(&pow,.,_));
%put x=&x;
Joe
  • 62,789
  • 6
  • 49
  • 67
  • 1
    This post saved my day, in particular the note about the quote character and the `%sysfunc`... – B--rian Oct 15 '20 at 13:58