BookmarkSubscribeRSS Feed
RoHa
Calcite | Level 5

Hi @all.

 

After switching from local to server, we had to change some functions in our programming.

The reason behind this is the utf-8 compatibility. The version we use is SAS 9.4.

 

One function we had to change is compress to kcompress.

Which is quite painful since kcompress doesn't support modifier.

 

I've got a program that tries to fix telephone numbers.

data work.DQ;
	Phone='+49O64343565ABC'; output;
run;
data work.DQ; set work.DQ;
	DQ_Phone=compress(Phone,"0123456789+",'k');
run;

 

Do you have any idea how to extract a certain list of characters from one string and insert it into another without using compress and modifier?

 

Thanks a lot for any help!

 

Roman

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

You don't have to use kcompress, you only use it when the string might contain double or more byte characters - and if you phone numbers contain those I would be worried.  Anyways, work around it by something like:

compress(kcompress(phone,""),"01234567890+")
RoHa
Calcite | Level 5

Unfortunately there is a good chance a phone number could contain ä,ü,ö

 

 

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

But those are single byte characters so shouldn't cause an issue for compress?

RoHa
Calcite | Level 5
are you sure? because testing revealed problems with them in the utf-8 environment and I think they are double byte characters. For Example: ä should be 11000011 10100100 in UTF-8 binary
RW9
Diamond | Level 26 RW9
Diamond | Level 26

If you can provide some example - test data in the form of a datastep - which illustrates your issue I can look, but this:

data have;
  a="abcdäefg1234";
  b=compress(a,"","kd");
run;

Works fine for me.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 5 replies
  • 1174 views
  • 0 likes
  • 2 in conversation