@Banu2318 wrote:
Due to security reason we can't store it into macro variable.
There is no reason you couldn't use a macro variable. I suspect the issue you have is you don't want the code/decode pairs printed to the SAS log, but you can easily prevent that.
But there shouldn't be any need to store the code/decode strings into macro variables. It will be easier to keep them in dataset variables anyway. Your current structure is inefficient of use, so first transform it so you have FROM and TO variables you use with the TRANSLATE function.
data lookup_fixed;
length from to $256 ;
do until (eof);
set lookup;
substr(from,_n_,1)=unmasked;
substr(to,_n_,1)=masked;
end;
drop unmasked masked;
run;
Now to transform your ACCOUNT_DETAILS dataset you can use something like this:
data account_details_masked ;
if _n_=1 then set lookup_fixed;
set account_details;
account_id = translate(account_id,to,from);
drop from to;
run;
You could easily extend that to multiple variables by using an ARRAY.
For example if in addition to ACCOUNT_ID you also wanted to mask NAME and ADDRESS.
data account_details_masked ;
if _n_=1 then set lookup_fixed;
set account_details;
array mask account_id name address ;
do index=1 to dim(mask);
mask[index] = translate(mask[index],to,from);
end;
drop from to index;
run;
... View more