Hi all, My aim is to remove a specific set of characters from a string. I want to specify the set of characters to be removed by using a variable, instead of explicitly writing the characters in the prx function. The code chunk below works, but instead of specifying 'W28' inside the prxchange function, I want to list a variable because the value could be different for every row that this function is iterated over. data temp;
input id 1 ICD $ 3-5 MoreICDs $ 7-17;
datalines;
1 W28 W75 V86 X47
2 W75 W28 W75 X47
3 C67 W75 V86 X47
;
run;
data temp2;
set temp;
string1=prxchange('s/W28*//i',-1,MoreICDs);
*put string1=;
run; What I want is something similar to the code chunk below where I replaced the value, 'W28' with the variable, ICD, inside the prxchange function but this syntax is not valid, obviously. data temp;
input id 1 ICD $ 3-5 MoreICDs $ 7-17;
datalines;
1 W28 W75 V86 X47
2 W75 W28 W75 X47
3 C67 W75 V86 X47
;
run;
data temp2;
set temp; length FinalICDs $11;
FinalICDs=prxchange('s/',ICD,'*//i',-1,MoreICDs);
run; The output I want is: ID ICD MoreICDs FinalICDs 1 W28 W28 W75 X47 W75 X47 2 W75 W28 W75 X47 W28 X47 3 C67 W75 V86 X47 W75 V86 X47 I've researched for awhile now and hoping someone in this community can help. Thanks! John
... View more