BookmarkSubscribeRSS Feed

Change UTF-8 encoding SAS dataset into EUC-CN encoding SAS dataset

Started ‎01-18-2021 by
Modified ‎01-18-2021 by
Views 10,031

Actually, it is not a paper .

I just want share an idea and SAS code to somebody who need it in the future.

 

Sometimes, I received a SAS dataset which encoding is utf-8,

but my running sas session is euc-cn encoding.

When I opened it and it get messy and unreadable  characters .

Like this :

 

messy.png

 

 

I tried

 

data want(encoding=any);

set have;

run;

 

and

 

libname x cvp 'c:\temp' cvpmult=2;   

proc copy in=x out=work noclone;

run;

 

but still can't get job done.

 

Finally I found an workaround way to conquer this obstacle .

My basic idea is first change utf-8 dataset into utf-8 csv file and import these csv file into euc-cn encoding sas .

 

1) copy " UTF8_SAS.sas "  and " Chinese_SAS.sas "  into the fold which contains the utf-8 encoding sas datasets. (Check attachment)

Like this :

data_code.png

 

2)  Open utf-8 encoding SAS .  and running  sas code   "  UTF8_SAS.sas "   under it .

Like this :

unicode.png

 

 

 

 

3) Open Chinese SAS (euc-cn encoding).   and running sas code "  Chinese_SAS.sas "  under it .

Like this :

chinese.png

 

 

 

4) and could get a fold named SAS under the same fold .

Like this :

sas.png

 

5) the sas datasets under SAS fold are what I want.

i.e. the sas datasets under SAS fold have encoding 'euc-cn' .

x.png

 

 

6) Open these sas datasets  under SAS fold could get the right Chinese characters .

P.S. this way also could work on Japanese or Korean SAS dataset which encoding is utf-8.

good.png

Comments

Hi Xia, @Ksharp  Requesting to add more comments to make little more comprehensive when and if you have time and at your own convenience. Thank you.

@novinosrin  ,

Do you have any questions ? You would meet Chinese characters in your routine work ?

Oh Not really. However, A friend of mine who is Chinese or I guess Chinese-Singaporean works for Standard Chartered in Singapore. I often talk to him about you and he follows your solutions closely. So yeah, he uses chinese characters in his routine work. Therefore, I make it a point to make him aware of any new major contributions you make. 🙂

Contributors
Version history
Last update:
‎01-18-2021 07:44 AM
Updated by:

SAS AI and Machine Learning Courses

The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.

Get started

Article Tags