****************************************************************************************************
****************************************************************************************************
* PROGRAM: attrition_output.sas
* Created (mm/dd/yyyy): 05/18/2021
*--------------------------------------------------------------------------------------------------
* PURPOSE: This macro outputs patient and/or episode level attrition data
* - agg_patient_attrition
* - agg_episode_attrition
* -repdata.table&tablenum.&tableletter.
* -tabletype - patient - Output patient level attrition table
* - episode - Output episode level attrition table
*--------------------------------------------------------------------------------------------------
* Sentinel Coordinating Center
* info@sentinelsystem.org
***************************************************************************************************;
%macro attrition_output(tabletype=);
%if &&attrition_&tabletype > 0 %then %do;
%if %index(&reporttype,T4) > 0 %then %let num_fn = 1; %else %let num_fn = 0;
%let claim_level_descr = &tabletype.;
data repdata.table&tablenum.&tableletter.;
set agg_&tabletype._attrition&attrperiodid;
if index(lowcase(report_descr), 'evidence of')>0 then do;
call symputx('num_fn', %eval(&num_fn.+1));
if claim_level = 'MIL' then call symputx('milexcl', 'Y'); /*to mark which row to apply superscript*/
if claim_level ne 'MIL' then call symputx('exclincl', 'Y');
%if %index(&reporttype,T4) %then %do; call symputx('claim_level_descr', 'Pregnancy episodes'); %end;
%else %if &tabletype = episode %then %do; call symputx('claim_level_descr', 'Episodes'); %end;
%else %if &tabletype = patient %then %do; call symputx('claim_level_descr', 'Patients'); %end;
%if %index(&reporttype,T2L2) %then %do;
length monitoringperiod 3;
%if %eval(&num_fn.>0) %then %do;
set lookup.lookup_footnotes (where = (type = "attrition"