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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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