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

Hi All,

I need to import excel spreadsheets containing Hex and convert it to the Chinese language so it can then be translated. An example is I need to convert:

73B0572865B94FBF62537ED94F605417 to

现在方便打给你吗

Is there a way this can be done? I've googled it to death but have yet to find an answer.

Many thanks in advance

Steve

1 ACCEPTED SOLUTION

Accepted Solutions
FriedEgg
SAS Employee

This is because the SAS session you started is most likely run with 'English' encoding and not 'Unicode.'  So, while you are properly performing the encoding you are unable to store/view the unicode characters with the given session settings.

View solution in original post

7 REPLIES 7
FriedEgg
SAS Employee

data _null_;

input foo $hex32.;

bar=unicode(foo,'utf16b');

put bar;

cards;

73B0572865B94FBF62537ED94F605417

;

run;

SteveNZ
Obsidian | Level 7

Hiya,

I tried your code but it doesn't appear to work:

Is it a matter of finding the correct encoding?

cheers

Steve

37   data _null_ ;

38   input foo $hex32.;

39   bar=unicode(foo,'utf16b');

40   put bar;

41   cards;

NOTE: Argument 1 to function UNICODE('s°W(e¹O¿bS~Ù'[12 of 16 characters shown],'utf16b') at line 39

      column 5 is invalid.

RULE:      ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9---

42         73B0572865B94FBF62537ED94F605417

foo=s°W(e¹O¿bS~ÙO`T  bar=  _ERROR_=1 _N_=1

NOTE: DATA statement used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

44   run;

FriedEgg
SAS Employee

This is because the SAS session you started is most likely run with 'English' encoding and not 'Unicode.'  So, while you are properly performing the encoding you are unable to store/view the unicode characters with the given session settings.

jakarman
Barite | Level 11

Most sas installations are done wit a single byte Latin approach. Eguide is supporting utf8 that includes Chinese chars. When running sas in utf8 mode you should change your mind that 1 char is 1 byte. There are 1 to 4 bytes representing 1 char. Your reading and conversion of chars should go automatic. The challenge is that some coding habits need to change.

---->-- ja karman --<-----
SteveNZ
Obsidian | Level 7

Thanks for your help, I should be able to get things working from here.

Ksharp
Super User

I tested Matt's code . It is right . I never realize SAS has such function ,must >=9.3  .

FriedEgg
SAS Employee

,


I believe this function was added to SAS as a pre-production feature in 9.1.3 and then officially in 9.2

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 4055 views
  • 3 likes
  • 4 in conversation