DATA Step, Macro, Functions and more

I want to strip special characters from SAS data

Reply
N/A
Posts: 0

I want to strip special characters from SAS data

I have a SAS dataset that has a variable that contains carriage returns, line feeds, and form feeds. I want to remove these without affecting any other data. I tried the COMPRESS function with the "s" modifier but I also removed blanks.....which is not good. Any ideas on how to remove just the three types of characters I mentioned? Thanks in advance.
Super Contributor
Super Contributor
Posts: 3,174

Re: I want to strip special characters from SAS data

Posted in reply to deleted_user
Suggest you share the exact SAS code used with COMPRESS - I would expect you might check TRANSLATE as well. Post the code and the related SAS log output info to your post with a pasted reply - consider adding some PUTLOG command logic with a hex-format output display to confirm the BEFORE / AFTER (new variable assignment) -- should help with your self-diagnosis desk checking.

Scott Barry
SBBWorks, Inc.
Contributor
Posts: 20

Re: I want to strip special characters from SAS data

Posted in reply to deleted_user
I think you might need the 'c' modifier instead of the 's' modifier. See http://www2.sas.com/proceedings/sugi31/028-31.pdf for more on using the compress function.
N/A
Posts: 0

Re: I want to strip special characters from SAS data

Thanks to both of you. I'm deciding between both of these options. I just need to determine if I want remove the characters or replace them with something else....like a space for ease of readability.
New Contributor
Posts: 4

Re: I want to strip special characters from SAS data

Posted in reply to deleted_user
I would also suggest rank() and byte() functions.
@agdesilva
Ask a Question
Discussion stats
  • 4 replies
  • 2011 views
  • 0 likes
  • 4 in conversation