I have a table with 100k + rows.
I'm trying to remove all instance of several sub-strings from one of the fields.
The method I found so far basically calls tranwrd for every offending sub-string.
There are three in the example below, but in the actual data sets there are quite a few more.
data mytable;
infile datalines delimiter=':' truncover;
informat myfield $50. someval 3.;
input myfield someval;
datalines;
some value xx abc:10
another values:15
random stuff ccc:1
more stuff xx:2
example abc:44
foo abc bar:55
sub xx string:11
;
run;
proc sql;
update mytable set myfield = strip(tranwrd(myfield,'abc',''));
update mytable set myfield = strip(tranwrd(myfield,'ccc',''));
update mytable set myfield = strip(tranwrd(myfield,'xx',''));
quit;
Is there was to get the same done with a single statement ?
I.e. given a full list of strings to delete, delete them all.
something along the lines of:
update mytable
set myfield = somefunction(myfield,/'abc','ccc','xx'/,'')
Thank you
With some more poking around, came up with below:
data mytable2;
set mytable;
n_myfield = myfield;
length word $50;
do word = 'abc','ccc','xx';
n_myfield = tranwrd(n_myfield,word,'');
end;
n_myfield = compbl(n_myfield);
drop word;
run;
does the trick without nesting (I really don't want to nest 10-15 tranwrd calls) or multiple nearly identical update statements.
regex is something I was hoping to use