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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1119 views
  • 0 likes
  • 2 in conversation