BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Anuz
Quartz | Level 8

Hi All,

 

I have a situation where in strings can have special characters i.e. names with Umlaut's.

 

For example :

Is there a way for example :CREACIONES PAZ RODRíGUEZ S L replaced with CREACIONES PAZ RODRA­GUEZ S L ?

But it can any character with umlaut's.

 

data aaa;
ORGNAME='PAZ RODRíGUEZ S L';
Run;

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

You can use the BASECHAR function.

--
Paige Miller

View solution in original post

4 REPLIES 4
s_lassen
Meteorite | Level 14

It may depend on your character set settings, but I had some problems with your example The obvious solution seems to be the good old TRANSLATE function, but that does not work, as 'Ã' seems to register as more than one character in my current SAS session:

 70         data _null_;
 71           set aaa;
 72           newname=translate(orgname,'A','Ã');
 73           put _all_;
 74         run;
 
 ORGNAME=PAZ RODRíGUEZ S L newname=PAZ RODRA ­GUEZ S L _ERROR_=0 _N_=1

The TRANWRD function works, on the other hand:

 70         data _null_;
 71           set aaa;
 72           newname=tranwrd(orgname,'Ã','A');
 73           put _all_;
 74         run;
 
 ORGNAME=PAZ RODRíGUEZ S L newname=PAZ RODRA­GUEZ S L _ERROR_=0 _N_=1

- only problem with that is that you may have to use several calls to get rid of different "strange" characters.

 

KTRANSLATE works better, as it can translate double-byte to single-byte characters (or the other way round):

 70         data _null_;
 71           ORGNAME='PAZ RODRíGUEZ S Lã';
 72           newname=ktranslate(orgname,'Aa','Ãã');
 73           put _all_;
 74         run;
 
 ORGNAME=PAZ RODRíGUEZ S Lã newname=PAZ RODRA­GUEZ S La _ERROR_=0 _N_=1

 

ErikLund_Jensen
Rhodochrosite | Level 12

Hi @Anuz 

 

No, I don't think SAS is able to recognise the "basic" character, but you can build your own translation table, like this:

 

108
109  data aaa;
110    ORGNAME='PAZ RODRíGUEZ S L';
111    NEWNAME = translate(ORGNAME,'A','Ã');
112    put ORGNAME=;
113    put NEWNAME=;
114  Run;

ORGNAME=PAZ RODRíGUEZ S L
NEWNAME=PAZ RODRA­GUEZ S L

You can supply a whole list of to-characters and from-characters in the same translate, see the. manual.

PaigeMiller
Diamond | Level 26

You can use the BASECHAR function.

--
Paige Miller
Anuz
Quartz | Level 8

@PaigeMiller  That resolved the issue. that is exactly what i was after. Thank you 

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
  • 4 replies
  • 1215 views
  • 9 likes
  • 4 in conversation