****************************************************************************************************
* PROGRAM OVERVIEW
****************************************************************************************************
*
* PROGRAM: appendix_driver.sas
* Created (mm/dd/yyyy): 02/25/2021
*
*--------------------------------------------------------------------------------------------------
* PURPOSE: This macro drives the creation of the report appendices
*
* Program inputs:
* - TABLEFILE
* - APPENDIXFILE
* -Excel file(s) containing code lists
*
* Program outputs:
* -tableofcontents: dataset containing table of contents
* -appendixreport: dataset containing appendix information for appendix_output.sas
* -datasets containing data to be output in appendix_output.sas
*
* PARAMETERS:
*
* Programming Notes:
*
*
*--------------------------------------------------------------------------------------------------
* CONTACT INFO:
* Sentinel Coordinating Center
* info@sentinelsystem.org
*
***************************************************************************************************;
%macro appendix_driver();
%put =====> MACRO CALLED: appendix_driver;
/*********************************************************************************************/
/* Utility macro to get check if a tab exists on an excel codelist file */
/*********************************************************************************************/
%macro xlsx_exist(libname,memname);
%local ret dsid;
%let ret=-1;
%let dsid = %sysfunc(open(sashelp.vmember(where=(libname=%upcase("&libname") and memname=%upcase("&memname")))));
%if &dsid %then %do;
%let ret=%eval(0=%sysfunc(fetch(&dsid)));
%let dsid=%sysfunc(close(&dsid));
%end;
&ret.
%mend xlsx_exist;
%let tablecount = 2; /* Appendix A is tablecount 1 */
/*********************************************************************************************/
/* Create HDPS Var Info appendices */
/*********************************************************************************************/
/* Create appendix for each unique runid periodid combination */
%isdata(dataset=agghdps);
%if &nobs > 0 and &numl2comparisons > 0 %then %do;
/* Rank hdps vars */
proc sort nodupkey data = agghdps;
by dpidsiteid psestimategrp analysisgrp subgroup subgroupcat periodid descending ranking frequency codecat codetype code;
run;
data agghdps;
set agghdps;
by dpidsiteid psestimategrp analysisgrp subgroup subgroupcat periodid descending ranking;
hdpsnum+1;
if first.periodid then hdpsnum = 1;
run;
/*loop through each periodid*/
%do periodid = %eval(&look_start.) %to %eval(&look_end.);
/* Loop through each ANALYSISGRP and determine if HDPS was used */
%do corder = 1 %to &numl2comparisons;
data _null_;
set l2comparisonfile(where=(order=&corder.));
call symputx('runid', runid);
call symputx('psestimategrp', psestimategrp);
call symputx('unique_psestimate',unique_psestimate);
if missing(topnhdps) then call symputx('topnhdps',25);
else call symputx('topnhdps',topnhdps);
call symputx('analysisgrp', analysisgrp);
run;
/* Set default values */
%let pscsfile = ;
%let hdps = N;
%let rank = ;