****************************************************************************************************
* PROGRAM OVERVIEW
****************************************************************************************************
*
* PROGRAM: t1t2conc_output.sas
* Created (mm/dd/yyyy): 09/21/2021
*
*--------------------------------------------------------------------------------------------------
* PURPOSE: This macro drives the creation of T1/T2 and Concomitant Tables proc report output
*
* Program inputs:
* - final_[t1cida/t2cida/t2conc]
* - final_dps_[t1cida/t2cida/t2conc]
*
* Program outputs:
* - repdata.table&tablenum.&tableletter
*
* PARAMETERS:
* - dataset = Input dataset (aggregated t1cida/t2cida/t2conc dataset)
* - varlist = List of character columns to be printed
* - stratavar = Stratification variable
* - varwidth = Width of variable
* - varsmallcells = Determine small cell count highlighting
* - title = Report title
*
* Programming Notes:
*
*
*--------------------------------------------------------------------------------------------------
* CONTACT INFO:
* Sentinel Coordinating Center
* info@sentinelsystem.org
*
***************************************************************************************************;
%macro t1t2conc_output(dataset=,varlist=,stratavar=,varwidths=,varsmallcells=,title=);
/*Create footnotes*/
%let outfootnotes=;
proc sql noprint;
select distinct footnote
into :outfootnotes
separated by "|"
from tablecolumns
where table="&reporttable" and not missing(footnote)
order by footnote;
quit;
data _footnotes;
length footnote_order 3;
set lookup.lookup_footnotes(where=(type = "t1t2conc" and order in ( 0
%if %index(&stratavar.,race) %then %do;
1
%end;
%if %str("&outfootnotes.") = %str("1") %then %do;
2
%end;
%if %str("&outfootnotes.") = %str("2") %then %do;
3
%end;
%if %str("&outfootnotes.") = %str("3") %then %do;
4
%end;
%if %str("&outfootnotes.") = %str("2|3") %then %do;
5
%end;
%if %str("&outfootnotes.") = %str("1|3") %then %do;
6
%end;
%if %str("&outfootnotes.") = %str("1|2") %then %do;
7
%end;
%if %str("&outfootnotes.") = %str("1|2|3") %then %do;
8
%end;
%if %index(&stratavar.,race) & &collapse_vars. = race %then %do;
9
%end;
)));
by order;
footnote_order = _n_;
run;
proc sql noprint;
select count(order) into: num_fn trimmed
from _footnotes;
%if &num_fn > 0 %then %do;
select description into: fn1 - :fn&num_fn.
from _footnotes
order by order;