From db195a831151298b3e10c3282b2741b56a208167 Mon Sep 17 00:00:00 2001 From: Ivor Townsend Date: Mon, 10 Jan 2022 16:33:44 +0000 Subject: [PATCH] fix: proc append warnings for file attributes --- base/mp_dirlist.sas | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/base/mp_dirlist.sas b/base/mp_dirlist.sas index 371ddbf..f2b7e5d 100644 --- a/base/mp_dirlist.sas +++ b/base/mp_dirlist.sas @@ -50,6 +50,9 @@

SAS Macros

@li mp_dropmembers.sas + @li mf_existds.sas + @li mf_getvarlist.sas + @li mf_wordsInStr1ButNotStr2.sas

Related Macros

@li mp_dirlist.test.sas @@ -194,8 +197,46 @@ data &out_ds; run; /* update main table */ -proc append base=&outds data=&out_ds; -run; + +/* The latest update may not match the base table as the addition of file +attributes is conditional, so cannot always use proc append as warnings may be +generated */ + +%if %mf_existds(&outds) %then %do; + + %if %length(%mf_getvarlist(&outds)) > %length(%mf_getvarlist(&out_ds)) %then + %do; + %let varstr1 = %mf_getvarlist(&outds); + %let varstr2 = %mf_getvarlist(&out_ds); + %end; + + %else %do; + %let varstr1 = %mf_getvarlist(&out_ds); + %let varstr2 = %mf_getvarlist(&outds); + %end; + + %if "%mf_wordsInStr1ButNotStr2( + Str1=&varstr1 + ,Str2=&varstr2 + )" ne "" %then %do; + + data &outds; + set &outds &out_ds; + run; + + %end; + + %else %do; + proc append base=&outds data=&out_ds; + run; + %end; + +%end; + +%else %do; + proc append base=&outds data=&out_ds; + run; +%end; /* recursive call */ %if &maxdepth>&level or &maxdepth=MAX %then %do;