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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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