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

There is a sas dataset and a variable Raw_Source has value as shown below( It is one value but the disorder has come to next line)

 

Raw_Source

Intestinal

Disorder

 

I used compress(raw_source,'kw') to get the result as "Intestinal Disorder". but instead the result comes as "IntestinalDisorder".

How to fix this issue? Any help is greatly appreciated.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

You're likely dealing with LF which you might get from importing data from Excel. I guess what you need is replacing such non-printable characters with a blank rather than just removing them.

Below using RegEx as the "big stick" to address any potential whitespace characters at once. Consecutive whitespace characters will be replaced with a single blank.

data have;
  Raw_Source='Intestinal'||'0A'x||'Disorder';
  Raw_Source2=prxchange('s/\s+/ /oi',-1,trim(raw_source));
  output;
  stop;
run;
proc print data=have;
run;

 

View solution in original post

2 REPLIES 2
SASKiwi
PROC Star

Are you confusing the COMPRESS and COMPBL functions? COMPRESS removes all spaces between words while COMPBL leaves single spaces between words: https://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=p1si0i16bcqti7n1jxxxe1hstunq.htm...

Patrick
Opal | Level 21

You're likely dealing with LF which you might get from importing data from Excel. I guess what you need is replacing such non-printable characters with a blank rather than just removing them.

Below using RegEx as the "big stick" to address any potential whitespace characters at once. Consecutive whitespace characters will be replaced with a single blank.

data have;
  Raw_Source='Intestinal'||'0A'x||'Disorder';
  Raw_Source2=prxchange('s/\s+/ /oi',-1,trim(raw_source));
  output;
  stop;
run;
proc print data=have;
run;