Hi Everyone,
I have one variable with the year. I want to remove the year. Could you let me know how to do so? Thank you!
For example,
Name
ABB3 (1942)
A12
A1E (2001)
AM2E (2012)
I want to have:
Name
ABB3
A12
A1E
AM2E
Hi,
you can try this:
data test;
input Name $20.;
name=scan(name,1,'(');
cards;
ABB3 (1942)
A12
A1E (2001)
AM2E (2012)
;
run;
There is a bunch of character string function that you can exploit, such as substr, findc...
This must be one of the most common topics (beside date handling), a lot of examples are available on these forums, and support.sas.com.
Look at the Scan function to get all the characters before the bracket "(".
Hi,
you can try this:
data test;
input Name $20.;
name=scan(name,1,'(');
cards;
ABB3 (1942)
A12
A1E (2001)
AM2E (2012)
;
run;
Hi pradeepalankar, LinusH, and Varunlyer,
Thank you for your help!
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.