****************************************************************************************************
****************************************************************************************************
* PROGRAM: baseline_aggregate.sas
* Created (mm/dd/yyyy): 10/20/2020
*--------------------------------------------------------------------------------------------------
* PURPOSE: The macro imports and concatenates both Level 1 and Level 2 baseline tables
* - Level 1 tables in the format: [runid]_baseline_[cohort]_[periodid].sas7bdat
* - Level 2 tables in the format: [runid]_adjusted_baseline_[periodid].sas7bdat
* - Dataset where each row represents a baseline metric and each column represents a DP value.
* Groups in the GROUPTABLE are stacked
* - dpsiteid: name of DP to import. Will be used as libname
- dpnumber: number to assign to each DP after transpose
* - grouptable: name of the dataset that contains groups, runIDs, and infomation pertaining to the
* baseline table name to include in the report.
* - outdata: name of the aggregated dataset
* - periodid: monitoring period #
* - This macro is designed to be called within a loop that loops through each data partner
* - For level 1 requests, the baseline table file name will be dynamically derived using
* &dpsiteid as the libname and the file name as: [runid]_baseline_[cohort]_&periodid
* - GROUPTABLE must contain the following variables: GROUP, RUNID, COHORT, and MERGEVAR
* For level 2 requests, only GROUP and RUNID need to be populated. GROUP will represent the ANALYSISGRP.
* For level 1 requests, COHORT is optional and will be used to correctly name the associated baseline
* table ([runid]_baseline_[cohort]_[periodid].sas7bdat), MERGEVAR is required and is the name of
* the key variable in the baseline table (group or analysisgrp)
* - It is assumed the user intends to import and aggregate all groups in the GROUPTABLE input file.
* The user should restrict this file to only groups with a baseline table prior to executing
*--------------------------------------------------------------------------------------------------
* Sentinel Coordinating Center
* info@sentinelsystem.org
***************************************************************************************************;
%macro baseline_aggregate(dpsiteid = ,
%put =====> MACRO CALLED: baseline_aggregate;
/*********************************************************************************************/
/* Level 1 baseline tables