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
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.