/**rawdata set looks like below*/
data rawdata ;
text="essay, an analytic, interpretative, or critical literary composition usually much shorter and less systematic and
formal than a dissertation or thesis
and usually dealing with its subject from a limited and often personal point of view";
run;
i have one rawdata like above one . with in a string we have multiple empty lines,tab spaces, unwanted spaces . How to remove all type of spaces except single embbded space.
I tried with few programs but I couldn't . coming like few words going to mix for example see bold letters 'and' 'formal' these words coming like "andformal".
My request is
The record should be like below if export this dataset:
"essay, an analytic, interpretative, or critical literary composition usually much shorter and less systematic and formal than a dissertation or thesis and usually dealing with its subject from a limited and often personal point of view"
I cannot tell from your share code what your variable actually contains.
If it just has spaces, as your code would generate, then just use COMPBL() to collapse the multiple adjacent spaces into one.
If it actual does have other invisible characters ( such as null, tab, line feed, carriage return, form feed, or non-breaking space) then first convert them into spaces.
data want;
set rawdata;
text = compbl(translate(text,' ','00090A0D0CA0'x));
run;
I cannot tell from your share code what your variable actually contains.
If it just has spaces, as your code would generate, then just use COMPBL() to collapse the multiple adjacent spaces into one.
If it actual does have other invisible characters ( such as null, tab, line feed, carriage return, form feed, or non-breaking space) then first convert them into spaces.
data want;
set rawdata;
text = compbl(translate(text,' ','00090A0D0CA0'x));
run;
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!
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.
Ready to level-up your skills? Choose your own adventure.