- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have a simple question for you experts.
I have a dataset where all the data are between double quotation marks.
Exemple:
"0.1%"
"0.00123321%"
and "" when there is no value.
How do I remove the quotations marks.
PS. I need to remove them in order to be able to do show descriptive statistics with the proc means function.
Thank you.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@AntoineA wrote:
Thank you both,
the compress command would not work for me the output data kept the "".
Try this:
newvariable=compress(oldvariable,'"');
That's a little hard to read, but after oldvariable, you type a comma, a single quote, a double quote and then another single quote. This removes the double-quotes from oldvariable, and creates newvariable without the double quotes.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use the COMPRESS function
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you both,
the compress command would not work for me the output data kept the "".
spread6m99=compress(spread6m,'"');
Instead I tried this:
spread6m99 = substr(spread6m,2,(length(spread6m)-3));
IF spread6m99='"' THEN spread6m99='';
seems to work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@AntoineA wrote:
Thank you both,
the compress command would not work for me the output data kept the "".
Try this:
newvariable=compress(oldvariable,'"');
That's a little hard to read, but after oldvariable, you type a comma, a single quote, a double quote and then another single quote. This removes the double-quotes from oldvariable, and creates newvariable without the double quotes.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can use the compress() function to do that. The syntax below should help clean up the fields, hope this helps!
newvar=compress(oldvar,'"');
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Alternatively try the perl regular expression function
data have;
input string$20.;
string2=prxchange('s/\"//',-1,string);
cards;
"0.1%"
"0.00123321%"
;
Thanks,
Jag
Jag
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
How do you get to these strings in quotes in first place?
If it's you reading in some text file then these quotes could already get removed in this extract step.