****************************************************************************************************
****************************************************************************************************
* PROGRAM: t1t2conc_createdata.sas
* Created (mm/dd/yyyy): 05/14/2021
*--------------------------------------------------------------------------------------------------
* PURPOSE: The macro produces tables for a standard Type 1 and Type 2 report
* - For Type 1 requests: agg_t1cida.sas7bdat
* - For Type 2 requests: agg_t2cida.sas7bdat
* - For Type 2 concomitance requests: agg_t1conc.sas7bdat
* - For Type 1 requests aggregation across all data partners: final_t1cida.sas7bdat
* - For Type 2 requests aggregation across all data partners: final_t2cida.sas7bdat
* - For Type 2 concomitance requests: final_t2conc.sas7bdat
* - For Type 1 requests by data partner: final_dps_t1cida.sas7bdat
* - For Type 2 requests by data partner: final_dps_t2cida.sas7bdat
* - For Type 2 concomitance requests by data partner: final_dps_t2conc.sas7bdat
* - for t1: table =t1_cida, grpvar = group
* - for t2: table =t2_cida, grpvar = group
* - for conc: table =t2_conc, grpvar = analysisgrp
*--------------------------------------------------------------------------------------------------
* Sentinel Coordinating Center
* info@sentinelsystem.org
***************************************************************************************************;
%macro t1t2conc_createdata(table =, grpvar = );
%put =====> MACRO CALLED: t1t2conc_createdata ;
/************************************************************************************************
Determine levels and stratifications
************************************************************************************************/
/* Confirm a table columns file has been specified */
%if %str("&tablecolumnsfile.") = %str("") %then %do;
%put ERROR: (Sentinel) Lookup table includes dataset &tdatasetlist., but tablecolumnsfile is not specified in &createreportfile. file.;
%let &table._stratification =;
/* Determine &table. levels and stratifications to store in macro variables*/
select distinct quote(strip(levelid1))
into :&table._levelid separated by ' '
from tablefile where dataset = "&table.";
select distinct tablesub into: &table._stratification separated by ' '
where tablesub ne 'overall' and dataset = "&table.";
/************************************************************************************************
Collapse data - if stratifybyDP = Y, need to reclassify prior to aggregation
if stratifybyDP = N, collapse after aggregation
************************************************************************************************/
%if %index(&&&table._stratification,race) & "&collapse_vars." = "race" %then %do;
/*identify sort order #*/
set stratavars_agg_&table.;
if strata = "race" then call symputx("sortnb",_n_);
%if &stratifybydp = Y %then %do;
%collapse_vars(dataset=agg_&table.,
where =level in (&&&table._levelid),
list=%str("American Indian or Alaska Native", "Asian", "Black or African American", "White", "Native Hawaiian or Other Pacific Islander"),
varlist=npts episodes adjustedcodecount rawcodecount daysupp amtsupp
%if %index(&table,conc) = 0 %then %do;
dennumpts dennummemdays timetocensor
%if %substr(&table,2,1) ne 1 %then %do;
eps_wevents all_events followuptime