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;

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1580 views
  • 1 like
  • 3 in conversation