A simple example, assuming you want to remove all the states using TRANWRD
I'm assuming you have the value I set in haveStr, and want to convert it to the value I have in wantStr. I suggest you provide a sample of the data you are attempting to transform, what you want as a result, what code you currently have and the log from that code
1456 data _null_ ;
1457 haveStr="Midwest (IA, IL, IN, OH, KS, MI, MN, MO, ND, SD, WI)" ;
1458 wantStr="Midwest" ;
1459
1460 convert=tranwrd(haveStr,"Midwest (IA, IL, IN, OH, KS, MI, MN, MO, ND, SD,
1460! WI)","MidWest") ;
1461
1462 put haveStr= ;
1463 put wantStr= ;
1464 put convert= ;
1465 run ;
haveStr=Midwest (IA, IL, IN, OH, KS, MI, MN, MO, ND, SD, WI)
wantStr=Midwest
convert=MidWest
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
Admin Note: Marking this as the Accepted Solution, as it has a link to the TRANWRD documentation Also, want to call out replies by:
@PaigeMiller which notes the importance of knowing your data:
The spaces and commas are critical if you are going to make TRANWRD work
@FreelanceReinh which offers a method to convert values that are "messy" inconsistent:
SLOE_1_Reg = prxchange('s/(\w+)\s*\(.+?\)/$1/',-1,SLOE_1_Reg);
Basically, this would replace substrings of the form "word (unwanted details)" with "word".
... View more