Appreciate if someone of you help me to write the 'case when ...' statement to derive the variable 'KHIREF' from the following data step?
data WORK.INSURANCE_POLICY_0002(drop=POLICY_NO checkdigit x_source_system_cd);
set WORK.INSURANCE_POLICY_0002;
format checkdigit z2.;
if POLICY_NO ^= '' then do;
/* combine source code and policy number */
khiref=substr(left(x_source_system_cd),2,1)!!substr(left(policy_no),1,2)!!substr(left(policy_no),4,7);
/* calculate the checkdigit modulo 97. replace 0 by 97 */
checkdigit=compress(mod(khiref,97));
if checkdigit=0 then checkdigit=97;
/* add the checkdigit */
khiref=substr(left(khiref),1,10)!!vvalue(checkdigit);
end;
run;
Sample data as follows:
data WORK.INSURANCE_POLICY_0002;
/*length POLICY_NO $20.;*/
POLICY_NO='94_0006288';
run;
... View more