****************************************************************************************************
****************************************************************************************************
* PROGRAM: process_inputfiles.sas
* Created (mm/dd/yyyy): 11/30/2020
*--------------------------------------------------------------------------------------------------
* PURPOSE: The macro reads in the CREATEREPORTFILE and other input files and merges in relevant
* QRP input file parameter values
*--------------------------------------------------------------------------------------------------
* Sentinel Coordinating Center
* info@sentinelsystem.org
***************************************************************************************************;
%macro process_inputfiles();
%put =====> MACRO CALLED: process_inputfiles ;
/***************************************************************************************************
* Read in CREATEREPORTFILE and assign each parameter to a macro variable
***************************************************************************************************/
%isdata(dataset=input.&createreportfile.);
%if %eval(&nobs<1) %then %do;
%put ERROR: (Sentinel) CREATEREPORTFILE is missing.;
%put ERROR: (Sentinel) Make sure file is specified correctly and placed in the inputfiles folder;
select count(*) into: numparms
from input.&createreportfile;
/*Assign all parameters to macro variables*/
%do createreportparameter = 1 %to %eval(&numparms.);
set input.&createreportfile;
if _n_ = &createreportparameter. then do;
call symputx("parameter", strip(parameter));
call symputx("value", strip(value));
if lowcase(parameter) in ('reporttype','stratifybydp','small_cellcounts','report_destination') then call symputx("value",upcase(value));
/*default report_destination is both*/
if lowcase(parameter) = 'report_destination' and missing(value) then call symputx("value","BOTH");
/*add parenthesis for datedistributed*/
if lowcase(parameter) in ('datedistributed') and missing(value)=0 then call symputx("value",cats('(', strip(value), ')'));
%let ¶meter. = &value.;
/***************************************************************************************************
* Check that REPORTTYPE is valid
***************************************************************************************************/
- T2L1: Level 1, type 2 report
- T2L2: Level 2, type 2 report
- T4L1: Level 1, type 4 report
- T4L2: Level 2, type 4 report
- TREE2: tree aggregation for Type 2
- TREE3: tree aggregration for Type 3
- TREE4: tree aggregation for Type 4 */
%if %sysfunc(prxmatch(m/T1|T2L1|T2L2|ITS|T4L1|T4L2|T5|T6|TREE2|TREE3|TREE4/i,&reporttype.)) <= 0 %then %do;
%put ERROR: (SENTINEL) REPORTTYPE parameter is invalid. Reporting tool will abort.;
/***************************************************************************************************
* Read in DPINFOFILE and mask DPs
***************************************************************************************************/
/*Check if DPINFOFILE exists and contains at least 1 DP to include in report*/