/*my problem is that tranwrd function is not working while using in macro with looping and passing macro var..*/
/*Problem to resolve*/
%let mvar1= rahim1 ramu1 sham1;
%let mvar= rahim ramu sham;
%let val=3;
data testing22;
rahim="good";
ramu="cool";
sham="fine";
rahim1="rahim";
ramu1="ramu";
sham1="akram";
a="from rahim";output;
a="from ramu";output;
a="from akram";output;
a="from aram";output;
a="from &sham";output;
a="from &sham;";output;
rahim="good";output;
ramu="cool";output;
sham="fine";output;
rahim1="rahim";output;
ramu1="ramu";output;
sham1="akram";output;
run;
options mprint mlogic symbolgen;
%MACRO Q4;
%do i=1 %to &val;
%LET m=%SCAN("&mvar",&i," ") ;
%LET k=%SCAN("&mvar1",&i," ") ;
data testing222;
set testing22;
F8=TRANWRD(a,trim(&k),trim(&m));* here this function is not working but htere is no error in log as well tried compress and other vars as well but nothing is working is there any other function also to replace the word in a string;
run;
%end;
%MEND;
%q4;
/*this is working fine without macro or do loop if we pass the var names manual.*/
data testing222;
set testing22;
F8=TRANWRD(a,rahim1,rahim);
run;