BookmarkSubscribeRSS Feed
NVK
Calcite | Level 5 NVK
Calcite | Level 5

My SAS session details are:-

ENCODING=LATIN1
LOCALE=EN_US

I am reading encrypted customer names, decrypting them using a java code that has been implemented in the sas code using javaobj.

data outlib.X1 ( ENCODING =  'asciiany' );
set inlib.INP1 (ENCODING = 'asciiany' )   end=eof;
length decryptedvalue  $100;
declare javaobj jObj("<jarname>");
jObj.callstringmethod("<method>", FIRST_NAME , decryptedvalue);
run;

The jObj.callstringmethod returns the decrypted first_name value in the string decryptedvalue. I do a proc export at the end of my SAS code and store all the decrypted names as csv files.

In the last run some of the names have special characters e.g. RÉAL.

This is causing SAS execution to fail with following error :-

ERROR: Transcoding failure at line 30 column 2.

ERROR: DATA STEP Component Object failure. Aborted during the EXECUTION phase.

Is there some way to make SAS session (LATIN1) accept these unicode characters? Can i set the encoding of the decryptedvalue variable? I dont want to run my entire SAS session in unicode using sas_u8. I only want to accept these characters Even reading these problematic values as blank is ok.

I have already tried following things :-

  1. Set inencoding= utf8 for the libname

  2. Make ENCODING = 'asciiany' for the input dataset.

Any inputs would be useful.

Thanks in advance!

2 REPLIES 2
ehbales
SAS Employee

The KPROPDATA function may help. You woudl need to pass in the string that is returned from Java. KPROPDATA would remove or convert any characters found in the string that are not supported by the SAS session encoding. Because you set the ENCOIDNG to ASCIIANY, you may need to specify the input and output encoding to the function. KPROPDATA is documented in the SAS National Language Support Reference Guide. 

 

As an alternative, if you own the Java code, you could call a method in Java that would convert to the Unicode escape representation. 

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 Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 3209 views
  • 3 likes
  • 3 in conversation