****************************************************************************************************
****************************************************************************************************
* PROGRAM: include_macros.sas
* Created (mm/dd/yyyy): 10/18/2021
*--------------------------------------------------------------------------------------------------
* PURPOSE: This macro %includes all .sas files in a specified directory except those explicitly
* - PROGRAM_DIR: location of directory containing programs to be included
* This program uses the %directory_listing utility macro that creates a SAS dataset with a
* listing of all files and folders in a directory.
* This utility macro have the following parameters:
* - PATH: unquoted full directory path
* - OUTDS: two-level SAS dataset name for the output table
* These standalone programs are excluded from the include list: create_lookup.sas, create_templatefiles.sas
*--------------------------------------------------------------------------------------------------
* Sentinel Coordinating Center
* info@sentinelsystem.org
***************************************************************************************************;
%macro include_macros(PROGRAM_DIR=);
%put =====> MACRO CALLED: include_macros;
%macro directory_listing(PATH=, OUTDS=);
%put =====> MACRO CALLED: directory_listing;
%local DREF DC DID OCOUNT N;
/* Assign fileref for the directory */
%let DC=%sysfunc(filename(DREF,&PATH.));
/* Assign directory ID by opening the path as a directory */
%let DID=%sysfunc(dopen(&DREF));
%put NOTE: Creating dataset &OUTDS with listing of &PATH. directory ;
/* Assign macro variable with the number of objects in the directory */
%let OCOUNT=%sysfunc(dnum(&DID));
/* Process each object in directory D */
%local ONAME&N O&N OREF&N RC&N OID&N ;
/* Assign name of the object (i.e. filename + extension) */
%let ONAME&N=%qsysfunc(dread(&DID,&N));