BookmarkSubscribeRSS Feed
yonib
SAS Employee
If I have this obs: yyy"y www qqq and i want to get yyyy without the space,
what should i do?
6 REPLIES 6
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Use the COMPRESS function in a SAS DATA step.

Scott Barry
SBBWorks, Inc.
yonib
SAS Employee
It will not solve my problem beacuse if i have yyy"y www qqq and
I will use compress(translate(var,' ' ,'"'));
The result will be this:yyyywwwqqq
And this is not what im looking for.....
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Read the DOC on the COMPRESS function and you will see that you can supply the specific character(s) to be compressed.

Scott Barry
SBBWorks, Inc.
deleted_user
Not applicable
use input them to indicate the line number
data temp;
input y 1-5 m ...;
then use compress to compress the variable y
them combine them in the way you like
Patrick
Opal | Level 21
The following code does what you asked for.
data _null_;
have='yyy y www qqq ';
have=tranwrd(have,'y y','yy');
put have=;
want=scan(have,1);
put want=;
run;

More general solutions would be possible - especially with RegEx - but you would have to tell us a bit more in detail what the problem is about you want to solve.
yonib
SAS Employee
Patrick and Sbb ,
Thanks alot for your program ideas.
thay help me alot!!!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1952 views
  • 0 likes
  • 4 in conversation