BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
vxhong17
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
pradeepalankar
Obsidian | Level 7

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

4 REPLIES 4
LinusH
Tourmaline | Level 20

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
VarunIyer
Calcite | Level 5

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

pradeepalankar
Obsidian | Level 7

Hi,

you can try this:

data test;

input Name $20.;

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

cards;

ABB3 (1942)

A12

A1E (2001)

AM2E (2012)

;

run;

vxhong17
Calcite | Level 5

Hi pradeepalankar, LinusH, and Varunlyer,

Thank you for your help!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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