%put WARNING: No data exists for treeanalysisid = &&tree&t.., treeanalysisgrp = &&treegroup&t.., level = &&levelid&t..&labelwarning.. Aggregate datasets will not be produced.;
************************************************************************************************
*************************************************************************************************
* PROGRAM: aggregate_tree.sas
* Created (mm/dd/yy): 04/28/2021
*--------------------------------------------------------------------------------------------------
* PURPOSE: Create analytic datasets that can be used as inputs to TreeScan software
* msoc.[RUNID]_t#_treeads_[TREEANALYSISID]_[LEVELID]_[LEVELNUM]_[PERIODID].sas7bdat
* msoc.[RUNID]_t3_tree_wkdays_[PERIODID]_agg.sas7bdat
* msoc.[RUNID]_t#_treeads_[TREEANALYSISID]_[LEVELID]_[LEVELNUM]_[PERIODID].sas7bdat
*------------------------------------------------------------------------------------------------
* Sentinel Coordinating Center
* info@sentinelsystem.org
***************************************************************************************************;
%do n = 1 %to &numrunid.;
%let runid = %scan(&runidlist., &n.);
%if %index(&reporttype., TREE) > 0 %then %do;
%let type = %substr(&reporttype,5,1);
%let type = %substr(&reporttype.,2,1);
/***********************************************************************************************
Identify EOI and REF for type 2 and 4
***********************************************************************************************/
*Get EOI/REF for type 2/4 analysis;
%if %eval(&type. ne 3) %then %do;
create table comparison as
select x.analysisgrp, y.eoi, y.ref
from infolder.&&&runid._psmatchfile. (keep=analysisgrp psestimategrp) as x
inner join infolder.&&&runid._psestimationfile. as y
on x.psestimategrp = y.psestimategrp;
/***********************************************************************************************
Determine if there is a t3treewkdays dataset created
***********************************************************************************************/
%if %sysfunc(exist(agg_t3_tree_wkdays_&periodid)) =1 %then %do;
select case when count(levelid) > 0 then 'Y'
else 'N' end into: run_t3wk
from infolder.&&&runid._userstrata. (where = (lowcase(tableid) = 't3treewkdays'));