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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 1165 views
  • 4 likes
  • 3 in conversation