BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
cb23_york
Obsidian | Level 7

Dear all, would appreciate your help on this.

I have an excel imported data sheet which for the most part looks fine.  Within this imported data I have one character variable which for some cases shows ...  Now if I try and select variables on the basis that this variable contains ... it selects none.  Furthermore when I hover my cursor over the the relevant box on the data screen the pop-up shows a blank line followed by some meaningful text underneath the blank line.  I'm guessing then that the character variable in this case is a carriage return followed by text.  I want to get rid off the CR and just have the text but I can't seem to get compress or trim to do the trick.  Does anyone have any suggestions?  Hope my question is clear enough.

Best wishes,   Chris

1 ACCEPTED SOLUTION

Accepted Solutions
sarathannapareddy
Fluorite | Level 6

The syntax for taking out all carriage return ('OD'x) and line feed ('OA'x) characters  is  

comment= Compress(comment,'0D0A'x);

comment= TRANWRD(comment,'0D0A'x,’’);


If you just want to take out the Carriage Return, use this code:  
comment= TRANWRD(comment,'0D'x,'');



Sarath

www.studysas.blogspot.com



View solution in original post

3 REPLIES 3
cb23_york
Obsidian | Level 7

I should add that the closest I have got to a solution is

varname = COMPRESS(varname, ' ',"s")

which does indeed get rid of the leading CR, but also unfortunately gets rid of all blanks in the text which is not quite what I want to do.

sarathannapareddy
Fluorite | Level 6

The syntax for taking out all carriage return ('OD'x) and line feed ('OA'x) characters  is  

comment= Compress(comment,'0D0A'x);

comment= TRANWRD(comment,'0D0A'x,’’);


If you just want to take out the Carriage Return, use this code:  
comment= TRANWRD(comment,'0D'x,'');



Sarath

www.studysas.blogspot.com



cb23_york
Obsidian | Level 7

The compress statement has worked a treat, many thanks Sarath.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 47905 views
  • 5 likes
  • 2 in conversation