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;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 429 views
  • 0 likes
  • 2 in conversation