****************************************************************************************************
****************************************************************************************************
* PROGRAM: _customize_input.sas
* Created (mm/dd/yyyy): 06/12/2023
*--------------------------------------------------------------------------------------------------
* PURPOSE: The macro allows for customization and saving of input files based on select tokens.
* Altered files will be saved to custom folder in inputfiles directory
* The custom folder will also be referenced as the first location in the infolder
* libref assignment, ensuring customized file will be used if one exists
* - modified version of inputfile saved to custom folder using same filename
*--------------------------------------------------------------------------------------------------
* Sentinel Coordinating Center
* info@sentinelsystem.org
***************************************************************************************************;
%* Create qcr specific version of lkp_all_flags. No other input files require modification for this workplan type;
%if %lowcase(&WPType.) = qcr
data custom.lkp_all_flags;
set infolder.lkp_all_flags;
if flagid not in ('DEM_2_07_00-0_227' ,'ENC_2_03_00-0_226', 'ENR_2_02_00-0_226','LAB_2_15_00-0_226','LAB_2_16_00-0_226', 'LAB_2_18_00-0_227')
and not(lowcase(tableid) = 'lab' and checkid in ('230', '231', '232', '234', '235'))
and not(lowcase(tableid) = 'lab' and CheckID = "222" and lowcase(Variable1) = "result_type" and lowcase(MS_Test_Name) ne "unmapped" );
%* adjust zip code lookup if parameter specified for length 3 value;
%if %sysfunc(exist(infolder.lkp_dem_zip,data)) %then %do;
data custom.lkp_dem_zip ( drop = PostalCode
rename = ( substrPostalCode = PostalCode ) );
length substrPostalCode $ 3;
set infolder.lkp_dem_zip;
substrPostalCode = cats(substr(PostalCode,1,3));
proc sort nodupkey; by Postalcode StateCode;
%* create backwards compatible through SCDM 8.0.0 version of lookups;
%* Update lkp_all_l1 to remove tabID/VarID introduced in SCDM to 8.2.0;
%* Ignore mods to valid values -- checks against earlier SCDM versions will run despite addition of new valid values;
if upcase(tabid) = 'ENR' and upcase(variable) in ("PLANTYPE", "PAYERTYPE")
else if upcase(tabid) = 'DEM' and upcase(variable) in ("IMPUTEDRACE", "IMPUTEDHISPANIC")
else output custom.lkp_all_l1;
%let remove_tabidList = ;
%* create parameters for combinations of tabid/variable name to iteratively remove lookups where applicable (flags and all_l2;
into :remove_tabidList separated by " "
, :remove_varList separated by " "
%if %length(&remove_tabidList.) >0
%then %do rn = 1 %to %sysfunc(countw(&remove_tabidList.));
%let remTabid = %scan(&remove_tabidList., &rn.);