****************************************************************************************************
****************************************************************************************************
* 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;
data repdata.table&tablenum.&tableletter.;
set agg_&tabletype._attrition;
%if &destination = excel %then %do;
ods excel options(sheet_name="Table &tablenum.&tableletter." tab_color="teal");
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.;
define agg_excluded_char / display 'Excluded' style(column)=[background=$backgroundfmt. tagattr="type:string"]
style(header)=[background = bgr borderleftcolor=bgr borderrightcolor=black borderrightwidth=1] format=$nafmt.;