Hi All,
The problem I met is that I want to convert unsupported characters to English characters in SAS.
For example, for text ASÃ, it needs to be ASA.
I dummy one dataset for testing.
data test;
infile datalines dsd;
input char $;
datalines;
FÉB
FÉBR
ASÃ
ASÍA
Ljusröd
Mörkröd
abc def
bd-fa
;
run;
Would you please help me with this?
Thanks!!!
You don't say what output you want. To convert alphabetic characters, use BASECHAR:
data test;
infile datalines dsd;
input char $;
asciiChar = basechar(char);
datalines;
FÉB
FÉBR
ASÃ
ASÍA
Ljusröd
Mörkröd
abc def
bd-fa
;
proc print data=test noobs; run;
char asciiChar FÉB FA‰B FÉBR FEBR ASà ASA ASÍA ASIA Ljusröd Ljusrod Mörkrö Morkro abc def abc def bd-fa bd-fa
There's no perfect 1:1 mapping, look into https://communities.sas.com/t5/SAS-Programming/Removing-non-Unicode-characters-from-a-variable/m-p/3...
You can try making translate rules like the following:
data have;
infile datalines dsd;
input char $;
datalines;
FÉB
FÉBR
ASÃ
ASÍA
Ljusröd
Mörkröd
abc def
bd-fa
;
run;
data want;
set have;
new_char=translate(upcase(char), 'A', 'Ã');
run;
Thanks a lot, unison. It's helpful.
You don't say what output you want. To convert alphabetic characters, use BASECHAR:
data test;
infile datalines dsd;
input char $;
asciiChar = basechar(char);
datalines;
FÉB
FÉBR
ASÃ
ASÍA
Ljusröd
Mörkröd
abc def
bd-fa
;
proc print data=test noobs; run;
char asciiChar FÉB FA‰B FÉBR FEBR ASà ASA ASÍA ASIA Ljusröd Ljusrod Mörkrö Morkro abc def abc def bd-fa bd-fa
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 16. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: