/**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 open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.