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!!!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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