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 7,319

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. 🙂

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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags