BookmarkSubscribeRSS Feed
nour_anwar
Fluorite | Level 6
data _null_;
	v1 = "aYT;-/*A - تwsilيتيتddيت يlămâieD  @يlămâieD D^)M";
	v2=upcase(v1);
	v3 = prxchange("s/[^-A-Z]/ /",-1,v2); 
    v4 = compress(v3, , 'kw');
put (_all_) (=/);
run; 

I want to keep only English characters ,hyphen "-" , and Arabic characters .this code worked fine for the  English characters and hyphen but it escape the Arabic characters  , how can I keep the Arabic characters  too !!

 

 

 

 

4 REPLIES 4
ChrisNZ
Tourmaline | Level 20

Moved and re-titled.

Did you try letter intervals like A-Z ? 

Or even adding all letters to the character class [ ]  ?

ChrisNZ
Tourmaline | Level 20

Also, if the Arabic letters are encoded using UTF-8, the "common" string functions (such as compress() or prxchange() ) will not work. You must use MBCS-aware functions, such as kcompress() . Not all single-byte functions have a multi-byte equivalent. 

andreas_lds
Jade | Level 19

I found this note in the docs of prxmatch:

This function is assigned an I18N Level 0 status, and is designed for SBCS data. Do not use this function to process DBCS or MBCS data.

Same problem with compress, fortunately kcompress exists, so maybe this is what you need:

data _null_;
	v1 = "aYT;-/*A - تwsilيتيتddيت يlămâieD  @يlămâieD D^)M";
	v2 = upcase(v1);
   v3 = kcompress(v2, , 'kw');
   put (_all_) (=/);
run; 
Ksharp
Super User
Not sure.
Could Try

Kcompress()
Ksubstr()
Klength()

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
  • 4 replies
  • 1072 views
  • 0 likes
  • 4 in conversation