****************************************************************************************************
****************************************************************************************************
* 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;
/* Identify if leave behind report is being created based on the existance of the report_parameters dataset.
Create macro variable to identify if it is a leave behind report */
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));
if lowcase(parameter) in ('customizecolumns', 'collapse_vars') then call symputx("value",lowcase(value));
/*default report_destination is both*/
if lowcase(parameter) = 'report_destination' and missing(value) then call symputx("value","BOTH");
if lowcase(parameter) = 'stratifybydp' and missing(value) then call symputx("value","N");
/*add parenthesis for datedistributed*/
if lowcase(parameter) in ('datedistributed') and missing(value)=0 then do;
tempvalue = input(value,ANYDTDTE32.); /*convert to SAS date*/
if missing(tempvalue) = 0 then do;
call symputx("value",cats('(', strip(put(tempvalue, worddate20.)), ')'));
call symputx("value",cats('(', strip(value), ')'));
%let ¶meter. = &value.;
/* If leave behind report is requested stratify by DP is set to N, report destination is PDF,
dpfile is set to the work dpinfofile and reportdata is N. */
%if &leavebehindreport = Y %then %do;
%let report_destination = PDF;
%let dpfile = dpinfofile;
/* Set reportid suffix to missing when not a leave behind report */
%let dpfile = input.&DPInfoFile.;