****************************************************************************************************
****************************************************************************************************
* 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.
*--------------------------------------------------------------------------------------------------
* Sentinel Coordinating Center
* info@sentinelsystem.org
***************************************************************************************************;
%macro attrition_output(tabletype=);
%if &&attrition_&tabletype > 0 %then %do;
%do n = 1 %to &numrunid.;
%let runid=%scan(&runidlist,&n);
data repdata.table&tablenum.&tableletter.;
set agg_&tabletype._attrition(where=(runid="&runid"));
%if &tabletype = episode %then %let titlelabel = %str(Episode);
%else %if &tabletype = patient %then %let titlelabel = %str(Patient);
%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 vjust=b borderbottomcolor=darkgrey bordertopcolor=darkgrey background=darkgrey] split='*'
style(report)=[rules=none frame=box cellpadding=1.5pt];
column report_descr (headerlabel,(grouplabel,(agg_remaining_char agg_excluded_char))) dummyvar;
define report_descr / group order=data ' ' style(column)=[rules=none just=L asis=on]
style(header)=[background = darkgrey borderleftcolor=darkgrey borderrightcolor=darkgrey];
define headerlabel / nozero across ' ' style(header)=[rules=none vjust=b bordertopcolor=black borderbottomcolor=black background=darkgrey borderrightcolor=black
borderleftcolor=black borderleftwidth=1 borderrightwidth=1];
define grouplabel / nozero across ' ' style(header)=[rules=none vjust=b bordertopcolor=black borderbottomcolor=black background=darkgrey borderrightcolor=black
borderleftcolor=black borderleftwidth=1 borderrightwidth=1];
define agg_remaining_char / display 'Remaining' style(column)=[background=$backgroundfmt. tagattr="type:string"]