Dear Community members, I have a dataset where I need to get all the hashed data into a macro variable & search that in original dataset. I am giving sample data below. I could do the code for one macro variable (hash_list1) , but not the other one (hash_list2). Can anyone help me how to write the code generically so that I can use the same code for hash_list1 & hash_list2. For example, you can use Macro Parameters so that this code can be used anywhere. Any help with this is appreciated. I have coded so that I can do it for hash_list1 and I don't want to repeat the same code for hash_list2. Could someone help me to write the code? Thanks in advance !!! options symbolgen mlogic mprint;
/* The total dataset */
data FullList;
do List = 1 to 1000000;
hash_list=upcase(put(sha256(strip(put(list,best.))||"d8pZpXvS0Q"),$hex64.));
output;
end;
run;
/* create hash_list1 & hash_list2 macros*/
data ValueList1;
call streaminit(1000000);
do i = 1 to 10000;
list1 = rand("integer", 100, 1000000);
hash_list1=upcase(put(sha256(strip(put(list1,best.))||"d8pZpXvS0Q"),$hex64.));
list2 = rand("integer", 1000, 1000000);
hash_list2=upcase(put(sha256(strip(put(list2,best.))||"d8pZpXvS0Q"),$hex64.));
output;
end;
run;
/* The number of records of the macro dataset*/
data ValueList2;
set ValueList1;
Count + 1;
call symputx('Count',Count);
run;
%put &Count.;
/* Break long macro into bins */
data _null_;
NumberBins=floor(&Count./500);
call symputx('NumberBins',NumberBins);
run;
%put &NumberBins. ;
/* get the values into macro variables */
%macro AddToBins();
%do BinCount = 0 %to &NumberBins.;
data _null_;
L=cats('L',&BinCount.);
call symputx('L',L);
run;
%global &L.;
proc sql noprint;
select "'"||strip(hash_list1)||"'" into :&L. separated by ','
from ValueList2
where &BinCount.*500 <= Count <= (&BinCount.*500)+(500-1) ;
quit;
%end;
%mend AddToBins;
%AddToBins;
%put &L0.***&L20. ;
/* code to include for the split macro variables*/
%macro splits (n_splits);
%local k;
%do k = 1 %to &n_splits;
hash_list in (&&L&k)
%if &k < &n_splits %then or;
%end;
%mend splits;
/* Search from original data to get the values from macro variables*/
data SearchResult2;
set FullList;
where(%splits (&NumberBins.));
run;
... View more