BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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.
4 REPLIES 4
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
sfleming
Calcite | Level 5
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.
deleted_user
Not applicable
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.
agdesilva
Calcite | Level 5
I would also suggest rank() and byte() functions.
@agdesilva

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 3576 views
  • 0 likes
  • 4 in conversation