****************************************************************************************************
* PROGRAM OVERVIEW
****************************************************************************************************
*
* PROGRAM: baseline_compute.sas
* Created (mm/dd/yyyy): 12/11/2020
*
*--------------------------------------------------------------------------------------------------
* PURPOSE: The computes aggregated baseline metrics and applies labels for each row of table
*
* Program inputs:
* - Aggregated baseline table with the following variables:
* - group1, group2 (optional)
* - order
* - metvar
* - vartype
* - switchstep (if reporttype = T6)
* - exp_mean1-exp_mean&num_dp
* - exp_std1-exp_std&num_dp
* - exp_s2_1-exp_s2_&num_dp
* - exp_w1_1-exp_w1_&num_dp
* - exp_w2_1-exp_w2_&num_dp
* - comp_mean1-comp_mean&num_dp (if group2 populated)
* - comp_std1-comp_std&num_dp (if group2 populated)
* - comp_s2_1-comp_s2_&num_dp (if group2 populated)
* - comp_w1_1-comp_w1_&num_dp (if group2 populated)
* - comp_w2_1-comp_w2_&num_dp (if group2 populated)
* - ad1-ad_&num_dp and sd1-sd_&num_dp (if group 2 populated and covar balance computed)
* - weight, table, subgroup, subgroupcat (if reporttype = T2L2 or T4L2)
*
* Program outputs:
* - Dataset with additional aggregated columns
*
* PARAMETERS:
* - datain: input dataset name
* - dataout: output dataset name
* - reporttype: Report type (type + level)
* - numbaselinetablegrp: number of baseline table groups
* - num_dp: number of data partners
* - stratifybydp: Y/N to format DP specific metrics
* - periodid: monitoring period #
*
*
* Programming Notes:
*
*
*--------------------------------------------------------------------------------------------------
* CONTACT INFO:
* Sentinel Coordinating Center
* info@sentinelsystem.org
*
***************************************************************************************************;
%macro baseline_compute(datain=, dataout=, reporttype=, numbaselinetablegrp=, num_dp=, stratifybydp=, periodid=);
%put =====> MACRO CALLED: baseline_compute;
/* Create a labels dataset for subgroup header creation */
data init_labels;
length label $&baselinelabellength sortorder1 sortorder2 3 sortorder3 sortorder4 8;
grouper='Demographic Characteristics';
sortorder1=3;
sortorder2=0;
sortorder3=0;
sortorder4=0;
label='Age';
output;
sortorder1=4;
label='Sex';
output;
sortorder1=5;
label='Race';
output;
sortorder1=6;
label='Hispanic origin';
output;
sortorder1=8;
label='Year';
output;
run;
***********************************************************************************************;
* Loop through each requested baseline table in BASELINEFILE
***********************************************************************************************;
%do b = 1 %to %eval(&numbaselinetablegrp.);
data _null_;
set baselinefile(where=(order=&b.));
if _n_ = 1 then do;
call symputx('analysisgrp', analysisgrp);
call symputx('runid', runid);