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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.