Hi all. I'm having a problem with a recursive subroutine in proc FCMP, which I'm using as an example in some training I'm doing. It is designed to get rid of multiple commas in a string. The function works fine for me if I copy it into standard data step code, but returns 'gobbldygook' characters when using FCMP and recursion. The following code illustrates: Dataset A comes back with the following value in variable teststring: " dÐdÐ,Dave,James,Bob". I've tried variations on the code, and the first 5 characters always come out as random special characters. Dataset B comes back with the correct string: "John,Jim,Dave,James,Bob" I'd really appreciate any help in understanding why it's not working properly. Thanks very much, Robin options cmplib=work.myfuncs; proc fcmp outlib = work.myfuncs.mylib; subroutine decomma(mystring $); outargs mystring; mystring = tranwrd(mystring,",,",","); a = index(mystring,",,"); if a > 0 then call decomma(mystring); endsub; run; data a; teststring = "John,,,Jim,,Dave,,,James,Bob"; call decomma(teststring); run; data b; mystring = "John,,,Jim,,Dave,,,James,Bob"; mystring = tranwrd(mystring,",,",","); mystring = tranwrd(mystring,",,",","); mystring = tranwrd(mystring,",,",","); mystring = tranwrd(mystring,",,",","); mystring = tranwrd(mystring,",,",","); mystring = tranwrd(mystring,",,",","); run;
... View more