remove characters!

Accepted Solution Solved
Reply
Contributor
Posts: 51
Accepted Solution

remove characters!

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


Accepted Solutions
Solution
‎01-17-2014 06:11 AM
Frequent Contributor
Posts: 106

Re: remove characters!

Hi,

you can try this:

data test;

input Name $20.;

name=scan(name,1,'(');

cards;

ABB3 (1942)

A12

A1E (2001)

AM2E (2012)

;

run;

View solution in original post


All Replies
Super User
Posts: 5,427

Re: remove characters!

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.

Data never sleeps
New Contributor
Posts: 4

Re: remove characters!

Look at the Scan function to get all the characters before the bracket "(".

Solution
‎01-17-2014 06:11 AM
Frequent Contributor
Posts: 106

Re: remove characters!

Hi,

you can try this:

data test;

input Name $20.;

name=scan(name,1,'(');

cards;

ABB3 (1942)

A12

A1E (2001)

AM2E (2012)

;

run;

Contributor
Posts: 51

Re: remove characters!

Posted in reply to pradeepalankar

Hi pradeepalankar, LinusH, and Varunlyer,

Thank you for your help!

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 217 views
  • 6 likes
  • 4 in conversation