- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I try to use "compress" to remove the letter or number from the string. Somehow it didn't work. Please let me know how to fix it.
ID_=compress(strip(upcase(ID)),'A0'x);
Below is some sample strings:
- BIPAP (BIPHASIC POSITIVE AIRWAY PRESSURE) DEPENDENCE, CHRONIC RESPIRATORY FAILURE
- CHRONIC RESPIRATORY FAILURE & VENT/TRACH DEPENDENT
I expect the result is shown below.
- (),
- & /
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This is a great situation where you should just look at the documentation. What option of the COMPRESS function removes numbers? What option of the COMPRESS function removes letters?
Documentation: https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lefunctionsref/n0fcshr0ir3h73n1b845c4aq58hz.htm
I'll get you started: remove letters
ID_=compress(strip(ID), ,'a');
I assign you the homework to figure out how to remove numbers.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Works for me. What error do you get?
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Works for me also. From where are you accessing the internet? Maybe a badly configured firewall interferes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
But you only asked it to remove that single character with the hexcode of A0.
COMPRESS(source ,< characters> ,< modifier(s)>)
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@ybz12003 wrote:
What's X for?
Why are you asking me? You posted the code:
ID_=compress(strip(upcase(ID)),'A0'x);
This code is requesting that any instances of the character represented by the hexadecimal code A0 be removed. That code is frequently used on Web pages as a non-breaking space so that multiple word phrases are not wrapped in the middle.
The letter X after a quoted string indicts a string literal in hexadecimal notation. Just like the letter D after a quoted string indicates a date literal in a style that the DATE informat can interpret.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
So, it seems like the code below works for the result I want, which needs to have three arguments instead of two.
ID_=compress(strip(upcase(ID_)), , 'A');
But I still don't understand why two arguments are not working.
ID_=compress(strip(upcase(ID_)), 'A');
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The first one is using the modifier A. The second one is just asking to remove the capital letter A.
COMPRESS(source ,< characters> ,< modifier(s)>)
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Why do you write in your original message about removing numbers, and then give no example where numbers should be removed?
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@ybz12003 wrote:
Because the actual data contain numbers and charater.
So to help all of us in the future, from now on, please give us representative examples that illustrate the ENTIRE problem; in this case, examples involving numbers, and examples involving characters.
Paige Miller