BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
WorkUser
Obsidian | Level 7

Is it possible to remove an apostrophe only at the end of a word in SAS EG query builder?

I have the following data:

  • EMPLOYEES' BANK
  • ARTISANS' BANK
  • TEACHERS' RETIREMENT SYSTEM
  • DEVELOPER'S MORTGAGE COMPANY

And would like a new computed column to show:

  • EMPLOYEES BANK
  • ARTISANS BANK
  • TEACHERS RETIREMENT SYSTEM
  • DEVELOPER'S MORTGAGE COMPANY

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Don't know if the query builder uses the TRANWRD function.

The tranwrd function replaces in the first parameter, the string found in the second parameter if present, with the third parameter. We use double quotes to encase a single quote to avoid syntax:"' " to indicate single quote followed by space.

 

If you have other characters that occur after the the single quote that are not letters that may indicate something else to change then repeat.

 

Here is an example with code:

data have;
  input var $30.;
datalines;
EMPLOYEES' BANK
ARTISANS' BANK
TEACHERS' RETIREMENT SYSTEM
DEVELOPER'S MORTGAGE COMPANY
;

data want;
   set have;
   var = tranwrd(var,"' "," ");
run;

View solution in original post

1 REPLY 1
ballardw
Super User

Don't know if the query builder uses the TRANWRD function.

The tranwrd function replaces in the first parameter, the string found in the second parameter if present, with the third parameter. We use double quotes to encase a single quote to avoid syntax:"' " to indicate single quote followed by space.

 

If you have other characters that occur after the the single quote that are not letters that may indicate something else to change then repeat.

 

Here is an example with code:

data have;
  input var $30.;
datalines;
EMPLOYEES' BANK
ARTISANS' BANK
TEACHERS' RETIREMENT SYSTEM
DEVELOPER'S MORTGAGE COMPANY
;

data want;
   set have;
   var = tranwrd(var,"' "," ");
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

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 1 reply
  • 639 views
  • 0 likes
  • 2 in conversation