Editor's Note: Thanks for the excellent solution. I have added a full code version down below.
Combining index- and substr-function seems to be a good start:
name = substr(name, 1, index(name, '(') -1);
Both functions are well documented:
index: http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/a000212242.htm
substr: http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/a000212264.htm
data one;
input name $1-24;
cards;
Leeds (212)
Wakefield (213)
Kingston-upon-Hull (215)
N Lincolnshire (216)
;
data two;
set one;
length new_name $24;
new_name=substr(name,1,index(name, '(')-1);
run;
proc print;
run;
Editor's Note: Thanks for the excellent solution. I have added a full code version down below.
Combining index- and substr-function seems to be a good start:
name = substr(name, 1, index(name, '(') -1);
Both functions are well documented:
index: http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/a000212242.htm
substr: http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/a000212264.htm
data one;
input name $1-24;
cards;
Leeds (212)
Wakefield (213)
Kingston-upon-Hull (215)
N Lincolnshire (216)
;
data two;
set one;
length new_name $24;
new_name=substr(name,1,index(name, '(')-1);
run;
proc print;
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.