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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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