This does not even do what you described.
data t;
VAR_HAVE = 'Members United Swaps With Other Parties';
NEW_VAR1 = strip(substr(VAR_HAVE,findw(upcase(VAR_HAVE),'WITH')+lengthc('with')));
NEW_VAR2 = strip(substr(VAR_HAVE,1,findw(upcase(VAR_HAVE),'WITH')-1));
run;
VAR_HAVE
NEW_VAR1
NEW_VAR2
Members United Swaps With Other Parties
Other Parties
Members United Swaps
A variation on @Shmuel's reply is the simplest:
data want;
set have;
length var2 $20;
var2 = substr(var1, findw(var1,'with',' ','i'));
run;
What's wrong with that?
... View more