Help using Base SAS procedures

compress single and double quote

Reply
Super Contributor
Posts: 304

compress single and double quote

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!
Contributor
Posts: 43

Re: compress single and double quote

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;
Super Contributor
Posts: 304

Re: compress single and double quote

thanks a lot kevin! got it now
Contributor
Posts: 20

Re: compress single and double quote

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;
Ask a Question
Discussion stats
  • 3 replies
  • 7084 views
  • 0 likes
  • 3 in conversation