****************************************************************************************************
****************************************************************************************************
* PROGRAM: t6censor_output.sas
* Created (mm/dd/yyyy): 10/22/2021
*--------------------------------------------------------------------------------------------------
* PURPOSE: This macro drives the creation of T6 Censoring tables
* - repdata.&tablenum.&tableletter
* - tablenum - Table Number and letter
* - dataset - T6 censoring dataset
* - censorreason - List of censoring reasons
* - dptable - Determine whether to use dpidsiteid column
*--------------------------------------------------------------------------------------------------
* Sentinel Coordinating Center
* info@sentinelsystem.org
***************************************************************************************************;
%macro t6censor_output(tablenum=,dataset=,title=,reasonlist=,where=,dptable=);
set lookup.lookup_footnotes(where = (type = "censor" and order in (1
%if %index(&reasonlist.,cens_episend) %then %do; 4 %end;
%if %index(&reasonlist.,cens_event) %then %do; 5 %end;
%if %index(&reasonlist.,cens_spec) %then %do; 6 %end;
%if %index(&reasonlist.,cens_dth) %then %do; 7 %end;
%if %index(&reasonlist.,cens_elig) %then %do; 8 %end;
%if %index(&reasonlist.,cens_dpend) %then %do; 9 %end;
%if %index(&reasonlist.,cens_qryend) %then %do; 10 %end;
%if %index(&reasonlist.,cens_switch) and &dataset=tableT9 %then %do; 11 %end;
%if %index(&reasonlist.,cens_switch) and &dataset=tableT10 %then %do; 12 %end;)));
select count(order) into: num_fn trimmed
%if %eval(&num_fn.>0) %then %do;
select description into: fn1 - :fn&num_fn.
/* Assign macro variables for superscipts */
%assign_superscripts(type =title, order =1);
%assign_superscripts(type =cens_episend, order =4);
%assign_superscripts(type =cens_event, order =5);
%assign_superscripts(type =cens_spec, order =6);
%assign_superscripts(type =cens_dth, order =7);
%assign_superscripts(type =cens_elig, order =8);
%assign_superscripts(type =cens_dpend, order =9);
%assign_superscripts(type =cens_qryend, order =10);
%assign_superscripts(type =cens_switch1, order =11);
%assign_superscripts(type =cens_switch2, order =12);
/* Save dataset to reportdata folder */
%isdata(dataset=repdata.table&tablenum.);
%if %eval(&nobs.<1) %then %do;
data repdata.table&tablenum.;
set &dataset(where=(&where.));
%do corder = 1 %to %sysfunc(countw(&defaultcensororder));
%let cen_var = %scan(&defaultcensororder., &corder.);
%if %index(&reasonlist.,&cen_var.)>0 %then %do;
%if &cen_var = cens_switch and &dataset = tableT9 %then %let cen_var = cens_switch1;
%if &cen_var = cens_switch and &dataset = tableT10 %then %let cen_var = cens_switch2;
if censorlabel = "&&&cen_var._label" then censorlabel="&&&cen_var._label.&&super_&cen_var.";