Hi SAS user,
can anyone tell me why my macros codes is not working?
%macro counts(code=,code_count=, age_code=, date_code=,label1=, label2=);
proc sort data=&lwork..crohns_count1;
by &id &claim_dt;
data &code (keep = &id &code_count &age_code &sex);
set &lwork..crohns_count1;
by &id &claim_dt;
where &code=1;
if first.&id then do;
&code_count=0;
&code_count+1;
&age_code=(&claim_dt-&dob)/365.25;
&date_code=&claim_dt;
end;
*keeps crohn's disease dx only--doesn't count uc9 dx;
if last.&id then output;
label &code_count=&label1;
label &date_code=&label2;
run;
proc freq data=&code;
table &code_count;
run;
/*generally people have more than 1 encounter*/
%mend; /*** is from counts macro ***/
%counts(code=cd9 , code_count=cd9_count , age_code=cd9_age_first , date_code=cd9_date_first ,
(label1='CD Code for ICD-9' , label2='Number of Crohns encounters in ICD-9',label3='Age of first CD diagnosis in ICD-9' , Label4='Date of first CD diagnosis in ICD-9' );
%counts(code=uc9 , code_count=uc9_count , age_code=uc9_age_first , date_code=uc9_date_first ,
(label1='UC Code for ICD-9', label2='Number of UC encounters in ICD-9', label3='Age of first UC diagnosis in ICD-9' , label4='Date of first UC diagnosis in ICD-9' );
%counts(code=cd10, code_count=cd10_count, age_code=cd10_age_first, date_code=cd10_date_first ,
(label1='CD Code for ICD-10' , label2='Number of CD encounters in ICD-10' , label3='Age of first CD diagnosis in ICD-10' , label4='Date of first CD diagnosis in ICD-10' );
%counts(code=uc10, code_count=uc10_count, age_code=uc10_age_first, date_code=uc10_date_first ,
(label1='UC Code for ICD-10', label2='Number of UC encounters in ICD-10' , label3='Age of first UC diagnosis in ICD-10', label4='Date of first UC diagnosis in ICD-10');