****************************************************************************************************
* PROGRAM OVERVIEW
****************************************************************************************************
*
* PROGRAM: t5tables_output.sas
* Created (mm/dd/yyyy): 08/25/2021
*
*--------------------------------------------------------------------------------------------------
* PURPOSE: This macro includes two proc report procedures in order to produce a categorical and
* continuous table in the report for Type 5 analyses
*
* Program inputs:
* - Dataset(s) computed in %t5tables_createdata
*
* Program outputs:
* - Dataset(s) to output/repdata for each figure
*
* PARAMETERS:
* - dataset: input dataset
* - reporttype: indicator whether to produce categorical (cat) or continuous (dist) metrics
*
* Programming Notes:
*
*
*--------------------------------------------------------------------------------------------------
* CONTACT INFO:
* Sentinel Coordinating Center
* info@sentinelsystem.org
*
***************************************************************************************************;
%macro t5tables_output(dataset=, reporttype=);
%put =====> MACRO CALLED: t5tables_output;
proc sql noprint;
select max(sortorder1), max(sortorder2)
into :maxorder1, :maxorder2
from &dataset.;
quit;
%put maxorder1 = &maxorder1.;
%put maxorder2 = &maxorder2.;
%let num_fn = 0;
%let tabletitle = ;
%let categories = ;
%let num_categories = 0;
%let num_fn=0;
data _null_;
set tablefile;
if "&dataset" = catx('_',table,put(stratificationorder,best.)) then do;
call symputx('tablesub', tablesub);
%if %sysfunc(prxmatch(m/T18_|T19_|T20_|T21_|T22_/i,&dataset.)) = 0 %then %do;
call symputx('categories', categories);
%end;
if tablesub = 'overall' and "&stratifybydp." = "Y" then call symputx('tabletitle', ', by Data Partner');
else call symputx('tabletitle', tabletitle);
end;
run;
/*Footnotes:
- footnote table for dose generated in tables footnotes generated in t5tables_createdata */
data _footnotes;
length footnote_order 3;
set %if %sysfunc(prxmatch(m/T18_|T19_|T20_|T21_|T22_/i,&dataset.)) > 0 %then %do;
%substr(&dataset.,1,3)_lookup_footnotes_dose(where=(order not in (0
%if &collapse_vars. ne race | %index(&tablesub., race)=0 %then %do;
2
%end;
)))
%end;
%else %do;
lookup.lookup_footnotes(where=(type = "t5tablefig" and order in (0
%if &collapse_vars. = race & %index(&tablesub., race)>0 %then %do;
2
%end;
)))
%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.