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

Hi,

 

I have a value and want to exclude anything in "()"

 

data:

test_code
Aspartate amino transferase (AST, SGOT)
Alkaline phosphatase (ALP)
Blood urea nitrogen (BUN)

want:

test_code
Aspartate amino transferase 
Alkaline phosphatase 
Blood urea nitrogen
1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

 

data have;
length str $100;
input str &;
datalines;
Aspartate amino transferase (AST, SGOT)
Alkaline phosphatase (ALP)
Blood urea nitrogen (BUN)
;

data want;
set have;
new_str = prxChange("s/\([^)]*\)//", 1, str);
run;

PGStats_0-1617229690723.png

 

PG

View solution in original post

3 REPLIES 3
PGStats
Opal | Level 21

 

data have;
length str $100;
input str &;
datalines;
Aspartate amino transferase (AST, SGOT)
Alkaline phosphatase (ALP)
Blood urea nitrogen (BUN)
;

data want;
set have;
new_str = prxChange("s/\([^)]*\)//", 1, str);
run;

PGStats_0-1617229690723.png

 

PG
SASKiwi
PROC Star

If it is always on the end:

data want;
  text = 'Aspartate amino transferase (AST, SGOT)';
  text_want = substr(text, 1, indexc(text, '(') - 1);
  put _all_;
run;
Ksharp
Super User
data have;
length str $100;
input str &;
datalines;
Aspartate amino transferase (AST, SGOT)
Alkaline phosphatase (ALP)
Blood urea nitrogen (BUN)
;

data want;
set have;
new_str = prxChange("s/\(.+?\)//", 1, str);
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1002 views
  • 0 likes
  • 4 in conversation