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 RODRAGUEZ S L ?
But it can any character with umlaut's.
data aaa;
ORGNAME='PAZ RODRÃGUEZ S L';
Run;
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 RODRAGUEZ 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 RODRAGUEZ S La _ERROR_=0 _N_=1
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 RODRAGUEZ S L
You can supply a whole list of to-characters and from-characters in the same translate, see the. manual.
You can use the BASECHAR function.
@PaigeMiller That resolved the issue. that is exactly what i was after. Thank you
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
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.
Ready to level-up your skills? Choose your own adventure.