BookmarkSubscribeRSS Feed
avinashaecwb
Obsidian | Level 7

I have data in excel file in Base64 format. Typical row is:

 

REF_NOACC_REF_NOFIN_YEARACCUSED_NAME
303325201620174KSm4KWA4KSqIOCkmuCkguCkpg==

 

I am trying to read this in SAS. Accused_Name is in Base64x format. If I decode it using generic websites on Google it returns "दीप चंद" which is Hindi text. I want the final result in English which should be "Deep Chand". How can I achieve this ? I am using below line of code to deocde base64 but it doesn't give even दीप चंद. 

 

%let name ='4KSm4KWA4KSqIOCkmuCkguCkpg==';
%let name_decode = (%sysfunc(inputc(%scan(&name,1,':')===,$base64x12.)));
%put &=name_decode;

2 REPLIES 2
alexal
SAS Employee

@avinashaecwb,

 

I would use something like that. Basically, you need to know the length of Base64 encoded string. So in your case, you can use $base64x28., instead of $base64x32767. 32767 is the max length of string when using Base64.

 

%let name ='4KSm4KWA4KSqIOCkmuCkguCkpg==';
%let name_decode = (%trim(%sysfunc(inputc(%scan(&name,1,':')===,$base64x32767.))));
%put &=name_decode;

 

avinashaecwb
Obsidian | Level 7

Hi @alexal - The output given by base64decode.org is दीप चंद . But if I execute the code in SAS, it doesn't give this result. I am assuming that is because दीप चंद is in Devnagri (Hindi) script. How can I force my SAS to decode the output in Devnagri script ? Would NLS help ? Finally, I need English output. So, first I need to Decode Base64 to Devnagri and then back to English.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1573 views
  • 0 likes
  • 2 in conversation