****************************************************************************************************
* PROGRAM OVERVIEW
****************************************************************************************************
*
* 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
*
* Program inputs:
* - For Type 1 requests: agg_t1cida.sas7bdat
* - For Type 2 requests: agg_t2cida.sas7bdat
* - For Type 2 concomitance requests: agg_t1conc.sas7bdat
*
* Program outputs:
* - 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
*
* PARAMETERS:
* - for t1: table =t1_cida, grpvar = group
* - for t2: table =t2_cida, grpvar = group
* - for conc: table =t2_conc, grpvar = analysisgrp
*
* Programming Notes:
*
*
*--------------------------------------------------------------------------------------------------
* CONTACT INFO:
* 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.;
%abort;
%end;
%let &table._stratification =;
proc sql noprint;
/* 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 ' '
from tablefile
where tablesub ne 'overall' and dataset = "&table.";
quit;
/************************************************************************************************
Summarize data
************************************************************************************************/
proc summary data = agg_&table. (where = (level in (&&&table._levelid))) nway missing;
class level &grpvar. %do s = 1 %to &&numstrata_&table.; sortorder&s. %end; &&&table._stratification;
var npts episodes adjustedcodecount rawcodecount daysupp amtsupp
%if %index(&table,conc) = 0 %then %do;
dennumpts dennummemdays timetocensor
%end;
%if %substr(&table,2,1) ne 1 %then %do;
eps_wevents all_events followuptime
%end;;
output out = agg_&table._sum (drop = _:) sum=;
run;
/************************************************************************************************
Determine total count of variables on table and put tablecolumns information into macro variables
************************************************************************************************/
proc sql noprint;
select count(column) into: numcolumns trimmed
from tablecolumns where table = "&table.";
select columnname
,column
,columnlabel
,columnformat
,scan(compress(column,'()'),1,'/') as numerator