BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
null
Fluorite | Level 6

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!!!

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

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
PG

View solution in original post

4 REPLIES 4
unison
Lapis Lazuli | Level 10

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;
-unison
null
Fluorite | Level 6

Thanks a lot, unison. It's helpful. Cat Happy

PGStats
Opal | Level 21

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
PG
null
Fluorite | Level 6
Thanks a lot PG! This is exactly what I want.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1889 views
  • 4 likes
  • 3 in conversation