****************************************************************************************************
****************************************************************************************************
* PROGRAM: createlibref.sas
* Created (mm/dd/yyyy): 11/28/2017
*--------------------------------------------------------------------------------------------------
* PURPOSE: This macro creates concatenated libref from a list of DPs and a file path,
* automatically defaults to most recent version, and checks for the existence of each folder path
* - dplist: list of DPs separated by a space
* - dpinfofile: file containing list of DPs and optional path
* - dataroot: location of /data folder in the standard structure /data/[version]/[dp]/msoc/
* - signaturefile: signature file from which to extract DP metadata
*--------------------------------------------------------------------------------------------------
* Sentinel Coordinating Center
* info@sentinelsystem.org
***************************************************************************************************;
%macro createlibref(dplist=,
**********************************************************
macro %dynamiclibref automatically creates libnames for
each DP based on K:/Sentinel folder structure
*********************************************************;
%macro dynamiclibref(dp_list=);
filename root "&dataroot.";
/*Retrieve each version*/
name=upcase(dread(did,i));
else put 'Could not open directory';
proc sort data=files_and_folders;
/*Put name of versions into macro variable*/
select lowcase(name) into: versions separated by ' '
where substr(upcase(name),1,1) = 'V' or substr(upcase(name),1,1) = 'B';
/*For each DP, confirm the existence of the directory. Only include directories that exist in the final concatenated libname*/
%let dp_list = %lowcase(&dp_list);
%let DpCnt = %sysfunc(Countw(&dp_list)); /*Number of DPs to loop*/
%let VerCnt = %sysfunc(Countw(&versions)); /*Number of versions to loop*/
%let DPSITEID = %scan(&dp_list,&a); /*Current DP*/
/*reset in_version counter*/
%let CurrVer = %scan(&versions,&b); /*Current version*/
/*does directory exist for current version?*/
%let dir = &dataroot./&CurrVer./&DPSITEID./msoc/;
%let rc = %sysfunc(filename(fileref,&dir)) ;
%if %sysfunc(fexist(&fileref)) %then %let in_version = &in_version &CurrVer;