****************************************************************************************************
****************************************************************************************************
* 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;
%let claim_level_descr = &tabletype.;
data repdata.table&tablenum.&tableletter.;
set agg_&tabletype._attrition;
if index(lowcase(report_descr), 'evidence of')>0 then do;
call symputx('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 %eval(&num_fn.>0) %then %do;
set lookup.lookup_footnotes_attrition;
select description into: fn1 - :fn&num_fn.
/* Assign macro variables for superscipts */
%assign_superscripts(type =exclincl, order = 1);
%if &destination = excel %then %do;
ods excel options(sheet_name="Table &tablenum.&tableletter." tab_color="teal" flow="tables");
ods proclabel = "Table &tablenum.&tableletter.";
proc report data=repdata.table&tablenum.&tableletter. nofs nowd spanrows missing
style(header)=[rules=none frame=void vjust=b borderbottomcolor=bgr bordertopcolor=bgr background=bgr borderleftcolor=bgr] split='*'
style(report)=[rules=none frame=void cellpadding=1.75pt];
column report_descr (headerlabel,(grouplabel,(agg_remaining_char agg_excluded_char))) dummyvar;
define report_descr / group order=data ' ' style(column)=[just=L]
style(header)=[background = bgr borderleftcolor= bgr borderrightcolor=bgr];
define headerlabel / nozero across ' ' style(header)=[rules=none vjust=b borderbottomcolor=black background=bgr borderrightcolor=black
borderleftcolor=black borderleftwidth=1 borderrightwidth=1];
define grouplabel / nozero across ' ' style(header)=[rules=none vjust=b bordertopcolor=black borderbottomcolor=black background=bgr borderrightcolor=black
borderleftcolor=black borderleftwidth=1 borderrightwidth=1];
define agg_remaining_char / display 'Remaining' style(column)=[background=$backgroundfmt. tagattr="type:string"]
style(header)=[background = bgr borderleftcolor=black borderleftwidth=1 borderrightcolor=bgr] format=$nafmt.;