****************************************************************************************************
****************************************************************************************************
* 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;
* Check if createreportfile has horizontal structure;
proc contents data=input.&createreportfile. noprint out=createreportfile_content;
%let parameter_variable_exists=0;
select count(*) into :parameter_variable_exists from createreportfile_content
where lowcase(name)="parameter";
%put &=parameter_variable_exists;
/* createreportfile has vertical structure */
%if ¶meter_variable_exists. > 0 %then %do;
set input.&createreportfile.;
/* createreportfile has horizontal structure */
select distinct name into :createreportfile_param_content separated by ' ' from createreportfile_content
%put &=createreportfile_param_content;
set input.&createreportfile.;
proc transpose data=&createreportfile.
out=&createreportfile.(rename=_name_=parameter);
var &createreportfile_param_content.;
/* 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
/*Assign all parameters to macro variables*/
%do createreportparameter = 1 %to %eval(&numparms.);