BookmarkSubscribeRSS Feed
milts
Pyrite | Level 9
hi all,

let's say i have a value '00012345

how can i remove the single quote or double quote?

if i use compress i'll get a compilation error since syntax for compress is
compress(var,"");

it is enclosed in double quotes so when you put a single quote and a double quote as your arguements, you wont be able to run the code. hope i was able to explain it correctly

are there any ways to remove quotes?

thanks in advance!
3 REPLIES 3
KevinQin
Obsidian | Level 7
The function COMPRESS should be OK.

Please try the code below:
data _null_;
a = "'00012345"""; *string with single quote and double quote;
put a=;
b = compress(a, "'""");
put b=;
run;
milts
Pyrite | Level 9
thanks a lot kevin! got it now
sfleming
Calcite | Level 5
There is also a third parameter to the compress function that can remove all characters of a certain type. For example, 'p' removes all punctuation characters.

data test;
x = "''x''";
y = '""y""';
z = cats(x, y);
w = compress(z,,'p');
run;
proc print data=test;
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3 replies
  • 18788 views
  • 0 likes
  • 3 in conversation