From 67ba2a5286a100a379f2b8a0e4d9c9b98893e3d9 Mon Sep 17 00:00:00 2001 From: Allan Bowe Date: Fri, 3 Jun 2022 17:45:27 +0000 Subject: [PATCH] fix: mp_abort on m6 win needs endsas --- all.sas | 61 ++++++++++++++++++++++----------------- base/mp_abort.sas | 53 ++++++++++++++++++++-------------- meta/mm_getfoldertree.sas | 8 ++--- 3 files changed, 70 insertions(+), 52 deletions(-) diff --git a/all.sas b/all.sas index 3718713..d50abbd 100644 --- a/all.sas +++ b/all.sas @@ -2200,16 +2200,20 @@ Usage: recognise this and fetch the log of the parent session instead) @li STP environments must finish cleanly to avoid the log being sent to _webout. To assist with this, we also run stpsrvset('program error', 0) - and set SYSCC=0. We take a unique "soft abort" approach - we open a macro + and set SYSCC=0. + Where possible, we take a unique "soft abort" approach - we open a macro but don't close it! This works everywhere EXCEPT inside a \%include inside a macro. For that, we recommend you use mp_include.sas to perform the include, and then call \%mp_abort(mode=INCLUDE) from the source program (ie, OUTSIDE of the top-parent macro). + The soft abort has also been found to be ineffective in 9.4m6 windows + environments. - @param mac= to contain the name of the calling macro + @param mac= (mp_abort.sas) To contain the name of the calling macro. Do not + use &sysmacroname as this will always resolve to MP_ABORT. @param msg= message to be returned - @param iftrue= supply a condition under which the macro should be executed. + @param iftrue= (1=1) Supply a condition for which the macro should be executed @param errds= (work.mp_abort_errds) There is no clean way to end a process within a %include called within a macro. Furthermore, there is no way to test if a macro is called within a %include. To handle this particular @@ -2230,11 +2234,12 @@ Usage: @li REGULAR (default) @li INCLUDE + @version 9.4 + @author Allan Bowe +

Related Macros

@li mp_include.sas - @version 9.4 - @author Allan Bowe @cond **/ @@ -2411,22 +2416,28 @@ Usage: rc=stpsrvset('program error', 0); call symputx("syscc",0,"g"); run; - /** - * endsas kills 9.4m3 deployments by orphaning multibridges. - * Abort variants are ungraceful (non zero return code) - * This approach lets SAS run silently until the end :-) - * Caution - fails when called within a %include within a macro - * Use mp_include() to handle this. - */ - filename skip temp; - data _null_; - file skip; - put '%macro skip();'; - comment '%mend skip; -> fix lint '; - put '%macro skippy();'; - comment '%mend skippy; -> fix lint '; - run; - %inc skip; + %if &sysscp=WIN and "%substr(&sysvlong. ,1,9)"="9.04.01M6" %then %do; + /* skip approach (below) does not work on this OS / version combo */ + endsas; + %end; + %else %do; + /** + * endsas kills 9.4m3 deployments by orphaning multibridges. + * Abort variants are ungraceful (non zero return code) + * This approach lets SAS run silently until the end :-) + * Caution - fails when called within a %include within a macro + * Use mp_include() to handle this. + */ + filename skip temp; + data _null_; + file skip; + put '%macro skip();'; + comment '%mend skip; -> fix lint '; + put '%macro skippy();'; + comment '%mend skippy; -> fix lint '; + run; + %inc skip; + %end; %end; %else %if "&sysprocessmode " = "SAS Compute Server " %then %do; /* endsas kills the session making it harder to fetch results */ @@ -16214,17 +16225,15 @@ filename __outdoc clear; Usage: - options ps=max nonotes nosource; - %mm_getfoldertree(root=/My/Meta/Path, outds=iwantthisdataset) - options notes source; + options ps=max nonotes nosource; + %mm_getfoldertree(root=/My/Meta/Path, outds=iwantthisdataset) + options notes source; @param [in] root= the parent folder under which to return all contents @param [out] outds= the dataset to create that contains the list of directories @param [in] mDebug= set to 1 to show debug messages in the log -

SAS Macros

- @version 9.4 @author Allan Bowe diff --git a/base/mp_abort.sas b/base/mp_abort.sas index 6ac9bfb..b27b4d2 100644 --- a/base/mp_abort.sas +++ b/base/mp_abort.sas @@ -15,16 +15,20 @@ recognise this and fetch the log of the parent session instead) @li STP environments must finish cleanly to avoid the log being sent to _webout. To assist with this, we also run stpsrvset('program error', 0) - and set SYSCC=0. We take a unique "soft abort" approach - we open a macro + and set SYSCC=0. + Where possible, we take a unique "soft abort" approach - we open a macro but don't close it! This works everywhere EXCEPT inside a \%include inside a macro. For that, we recommend you use mp_include.sas to perform the include, and then call \%mp_abort(mode=INCLUDE) from the source program (ie, OUTSIDE of the top-parent macro). + The soft abort has also been found to be ineffective in 9.4m6 windows + environments. - @param mac= to contain the name of the calling macro + @param mac= (mp_abort.sas) To contain the name of the calling macro. Do not + use &sysmacroname as this will always resolve to MP_ABORT. @param msg= message to be returned - @param iftrue= supply a condition under which the macro should be executed. + @param iftrue= (1=1) Supply a condition for which the macro should be executed @param errds= (work.mp_abort_errds) There is no clean way to end a process within a %include called within a macro. Furthermore, there is no way to test if a macro is called within a %include. To handle this particular @@ -45,11 +49,12 @@ @li REGULAR (default) @li INCLUDE + @version 9.4 + @author Allan Bowe +

Related Macros

@li mp_include.sas - @version 9.4 - @author Allan Bowe @cond **/ @@ -226,22 +231,28 @@ rc=stpsrvset('program error', 0); call symputx("syscc",0,"g"); run; - /** - * endsas kills 9.4m3 deployments by orphaning multibridges. - * Abort variants are ungraceful (non zero return code) - * This approach lets SAS run silently until the end :-) - * Caution - fails when called within a %include within a macro - * Use mp_include() to handle this. - */ - filename skip temp; - data _null_; - file skip; - put '%macro skip();'; - comment '%mend skip; -> fix lint '; - put '%macro skippy();'; - comment '%mend skippy; -> fix lint '; - run; - %inc skip; + %if &sysscp=WIN and "%substr(&sysvlong. ,1,9)"="9.04.01M6" %then %do; + /* skip approach (below) does not work on this OS / version combo */ + endsas; + %end; + %else %do; + /** + * endsas kills 9.4m3 deployments by orphaning multibridges. + * Abort variants are ungraceful (non zero return code) + * This approach lets SAS run silently until the end :-) + * Caution - fails when called within a %include within a macro + * Use mp_include() to handle this. + */ + filename skip temp; + data _null_; + file skip; + put '%macro skip();'; + comment '%mend skip; -> fix lint '; + put '%macro skippy();'; + comment '%mend skippy; -> fix lint '; + run; + %inc skip; + %end; %end; %else %if "&sysprocessmode " = "SAS Compute Server " %then %do; /* endsas kills the session making it harder to fetch results */ diff --git a/meta/mm_getfoldertree.sas b/meta/mm_getfoldertree.sas index 95c0d1a..ad49f47 100644 --- a/meta/mm_getfoldertree.sas +++ b/meta/mm_getfoldertree.sas @@ -8,17 +8,15 @@ Usage: - options ps=max nonotes nosource; - %mm_getfoldertree(root=/My/Meta/Path, outds=iwantthisdataset) - options notes source; + options ps=max nonotes nosource; + %mm_getfoldertree(root=/My/Meta/Path, outds=iwantthisdataset) + options notes source; @param [in] root= the parent folder under which to return all contents @param [out] outds= the dataset to create that contains the list of directories @param [in] mDebug= set to 1 to show debug messages in the log -

SAS Macros

- @version 9.4 @author Allan Bowe