%let dir1=%str(/new/dirct/loct/userLoc/logfiles/);
%let pgmname=%str(SchdDent_20170615);
%let date=&sysdate;
%let time=&systime;
%let ext1=%str(log);
%let break=%str(-);
%let final1=&dir1&pgmname&date&break&time..&ext1;
%put &final1;
proc printto log="&final1";
run; quit;
options nocenter ls=132 ps=32000 obs=50 compress=char;
libname in3 '/new/dirct/loct/userLoc/dss20170615/';
*Macro to read in one month of Sched Dent;
%macro readSchdDent(fy);
libname inscen&fy. "/mainDb/publs/SchdDent/";
data force schdDent&fy.;
set inscen&fy..fy&fy.(keep = APPT_DT APPT_TIME SSN LASTNAME FIRSTNAME HIPAA_TAX1 HIPAA_TAX2 HIPAA_TAX3 HIPAA_TAX4 HIPAA_TAX5 SLOT_KEY FY FM);
if FM='01';
run;
proc append data = schdDent&fy. base = in3.schdDent_step1 (compress=char) force;
run;
proc datasets;
delete schdDent&fy.;
run;
%mend readSchdDent;
%readSchdDent(16);
%readSchdDent(17);
data _null_;
file inc; /* extrnal file Data Step used to write output from a PUT statement*/
input @; /* holds input rcd for the next INPUT statemnt within the same iteration of the DATA step */
put _infile_; /* writes the last input data rcd read from the current input file or from data lines after DATELINES statenment */
cards4;
filename cp temp;
proc groovy classpath=cp;
add sasjar="commons_codec" version="1.4.0.0_SAS_20100917120335"; *version is specific to SAS Installation and may differ from this;
submit parseonly;
import javax.crypto.Mac
import javax.crypto.spec.SecretKeySpec
import org.apache.commons.codec.binary.Base64
class SASHash {
String base64hmacsha256(String key, String message) {
def mac = Mac.getInstance("HmacSHA256")
mac.init(new SecretKeySpec(key.getBytes(), "HmacSHA256"))
def hash = Base64.encodeBase64String(mac.doFinal(message.getBytes()))
return hash
}
}
endsubmit;
quit;
options set=classpath "%sysfunc(pathname(cp,f))";
;;;;
run;
* general purpose macro can be expanded to include additional methods;
%macro SASHash(action,key=key,message=message,return=hash,include=inc);
%goto &action;
%compile:
%include &include;
%return;
%declare:
if _n_=1 then declare javaobj SASHash('SASHash');
%return;
%base64hmacsha256:
SASHash.callStringMethod("&action",strip(&key),strip(&message),&return);
%return;
%mend;
%let key = sdfoij3242039sdflkj3r23w345v;
%SASHash(compile,include=inc)
data in3.schdDent_step1;
modify in3.schdent_step1;
%SASHash(declare)
length hashname $ 128;
%SASHash(base64hmacsha256,key="&key",message=ssn,return=ssn);
/*ssn = put(md5(upcase(trim(coalesce(ssn,''))) || '^' || '703447'),$hex32.)*/
lastname = put(md5(upcase(trim(coalesce(lastname,''))) || '^' || '703447'),$hex32.);
firstname = put(md5(upcase(trim(coalesce(firstname,''))) || '^' || '703447'),$hex32.);
run;
filename out1 '/new/dirct/loct/userLoc/dss20170615/schdDent.txt';
proc export data=in3.schdDent_step1
outfile=out1
dbms=dlm
replace;
delimiter='|';
run;
/*compresses a file with encryption by calling pkzip (available in AIX) */
data _null_;
call system ('pkzipc -add -passphrase=$@asdfsdf!@@# /new/dirct/loct/userLoc/dss20170615/schdDent.zip /new/dirct/loct/userLoc/dss20170615/schdDent.txt');
run; The original code revised w/ yours incorporated is shown above. After changing the version we ended up adding your recommendation verbatim right after the top Macro except the excerpt below we placed in the Data Step where we are hashing the ssn and return the result back to it. %SASHash(declare)
length hashname $ 128;
%SASHash(base64hmacsha256,key="&key",message=ssn,return=ssn); The code runs and returns hashed ssn values. We'll wait for any further remarks/comments/advice from your end before we close the thread. We thank you very much for your assistance and the time you put to develop an answer to our Q. S-
... View more