I have data that includes the name of a town in parenthesis. I want to get rid of what's in the parenthesis. Is there a way to do this in SAS...or does it need to be done outside of SAS?
Thanks in advance.
I will select the first word separated by "(" character with an scan function in the datastep
newvar=SCAN(var,1,'(');
Please show some sample data.
One approach, inside a data step is to include code similar to
Variable = substr(variable, 1,(index(variable,'(')-1));
This was very useful and did what I needed. Thank you for answering, however, I found the SCAN function much easier to use and most likely easier for me to remember in the future.
I will select the first word separated by "(" character with an scan function in the datastep
newvar=SCAN(var,1,'(');
Depending on your actual data, this might work (kicks out ( and ) without replacement):
Data A;
Ex="xxxcd(1dfd32)"; Output;
Ex="gegewx1d (322)"; Output;
Run;
Data B;
Set A;
Ex_new=PRXChange("s/[\(\)]//",-1,Ex);
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 how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.