11-14-2016 05:56 AM
My SAS session details are:-
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 :-
Set inencoding= utf8 for the libname
Make ENCODING = 'asciiany' for the input dataset.
Any inputs would be useful.
Thanks in advance!
11-14-2016 06:32 AM
01-06-2017 04:44 PM
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.