%macro search_by_group(letter,from_,to_,k, database, result);
data dummy;
set &database;
%do i=1 %to &k;
icd10d&i._letter=substr(icd10d&i,1,1);
icd10d&i._number=input(substr(icd10d&i,2,5),best12.);
%end;
run;
%do j=1 %to &k;
data dummy&k;
set dummy;
if icd10d&j._letter="&letter" and icd10d&j._number>=&from_ and icd10d&j._number<&to_ then condition=icd10d&j;/***it should be a double quotation here, not a single quotation***/
new_ppn=compress(put(ppn,12.))||condition;
run;
proc sort data=dummy&j nodupkey;
by new_ppn;
run;
%End;
data &result(keep=ppn new_ppn condition diseasename);
set dummy1-dummy&k;
diseasename=condition;
format diseasename icd10ff.;
run;
proc sort data=&result nodupkey;
by new_ppn;
run;
proc freq data=&result order=freq;
table condition diseasename ;
run;
%mend search_by_group;
%macro numpatients(database);
data &database._2;
set &database;
if diseasename='' then delete;
run;
proc sort data=&database._2 nodupkey;
by ppn;
run;
data numberpatients;
set &database._2;
No_Patients='Number of patients';
run;
title "Order and Number of patients in the &database block";
proc freq data=numberpatients;
table No_Patients;
run;
%mend numpatients;