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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.