BookmarkSubscribeRSS Feed
FatCaptain
Fluorite | Level 6
Hi,

I thought that this would be a fairly basic problem but I'm struggling for an answer.

I'm trying to remove single and double quote marks from a character variable.

The two statements I'm using to try do this are COMPRESS and TRANWRD. Both of these however, require you to put the character you want to remove inside quotation marks e.g.

COMPRESS(character-variable,''') ;
TRANWRD(character-variable,''','') ;

This obvously causes problems as the quotation mark I want to remove closes the second part of each statement.

Is there any way to get around this or another way of doing it?

Cheers,

Fat Captain.
4 REPLIES 4
data_null__
Jade | Level 19
Inside use two. See example.

[pre]
"""'"
or

'''"'

[/pre]
FatCaptain
Fluorite | Level 6
Cheers,

Thanks for this.
paulkaefer
Lapis Lazuli | Level 10

Another solution is the DEQUOTE function. Call dequote(variable) if the first character is a single or double quote character. It will also remove any text after the closing/right quote(s). [ref]

 

I know this is an older post, but it was one of the first results when searching this, so I figured including this solution here would be a good idea.

GenDemo
Quartz | Level 8
I ended up using word = compress(word,"""'");
as it said the call dequote function could not be found, and similairly if I use word = dequote(word); then it removed leading quotes, but not closing quotes.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 19476 views
  • 2 likes
  • 4 in conversation