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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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