From 86f6d06b85181c00313bade8a4ad7c55bff1a005 Mon Sep 17 00:00:00 2001
From: Allan Bowe <4420615+allanbowe@users.noreply.github.com>
Date: Thu, 19 May 2022 11:26:55 +0000
Subject: [PATCH 1/2] fix: update resetoption and adding test
---
base/mp_resetoption.sas | 26 +++++++++--------
tests/crossplatform/mp_resetoption.test.sas | 31 +++++++++++++++++++++
2 files changed, 46 insertions(+), 11 deletions(-)
create mode 100644 tests/crossplatform/mp_resetoption.test.sas
diff --git a/base/mp_resetoption.sas b/base/mp_resetoption.sas
index 796dc65..ac6ea7b 100644
--- a/base/mp_resetoption.sas
+++ b/base/mp_resetoption.sas
@@ -21,15 +21,19 @@ https://blogs.sas.com/content/sastraining/2012/08/14/jedi-sas-tricks-reset-sas-s
%macro mp_resetoption(option /* the option to reset */
)/*/STORE SOURCE*/;
-data _null_;
- length code $1500;
- startup=getoption("&option",'startupvalue');
- current=getoption("&option");
- if startup ne current then do;
- code =cat('OPTIONS ',getoption("&option",'keyword','startupvalue'),';');
- putlog "NOTE: Resetting system option: " code ;
- call execute(code );
- end;
-run;
-
+%if "%substr(&sysver,1,1)" ne "4" and "%substr(&sysver,1,1)" ne "5" %then %do;
+ data _null_;
+ length code $1500;
+ startup=getoption("&option",'startupvalue');
+ current=getoption("&option");
+ if startup ne current then do;
+ code =cat('OPTIONS ',getoption("&option",'keyword','startupvalue'),';');
+ putlog "NOTE: Resetting system option: " code ;
+ call execute(code );
+ end;
+ run;
+%end;
+%else %do;
+ %put &sysmacroname: reset option feature unavailable on &sysvlong;
+%end;
%mend mp_resetoption;
\ No newline at end of file
diff --git a/tests/crossplatform/mp_resetoption.test.sas b/tests/crossplatform/mp_resetoption.test.sas
new file mode 100644
index 0000000..3413fb7
--- /dev/null
+++ b/tests/crossplatform/mp_resetoption.test.sas
@@ -0,0 +1,31 @@
+/**
+ @file
+ @brief Testing mp_resetoption macro
+
+
SAS Macros
+ @li mp_assert.sas
+ @li mp_assertscope.sas
+ @li mp_resetoption.sas
+
+**/
+
+
+%let orig=%sysfunc(getoption(obs));
+
+options obs=30;
+
+%mp_assertscope(SNAPSHOT)
+%mp_resetoption(OBS)
+%mp_assertscope(COMPARE)
+
+%let new=%sysfunc(ifc(
+ "%substr(&sysver,1,1)" ne "4" and "%substr(&sysver,1,1)" ne "5",
+ %sysfunc(getoption(obs)), /* test it worked */
+ &orig /* cannot test as option unavailable */
+));
+
+%mp_assert(
+ iftrue=(&new=&orig),
+ desc=Checking option was reset (if reset option available),
+ outds=work.test_results
+)
From 88ddba2a4b9bec93e444e33a3ba27d21bef59047 Mon Sep 17 00:00:00 2001
From: Allan Bowe <4420615+allanbowe@users.noreply.github.com>
Date: Thu, 19 May 2022 11:27:39 +0000
Subject: [PATCH 2/2] fix: runall
---
all.sas | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/all.sas b/all.sas
index 47688b4..297493c 100644
--- a/all.sas
+++ b/all.sas
@@ -10277,17 +10277,21 @@ https://blogs.sas.com/content/sastraining/2012/08/14/jedi-sas-tricks-reset-sas-s
%macro mp_resetoption(option /* the option to reset */
)/*/STORE SOURCE*/;
-data _null_;
- length code $1500;
- startup=getoption("&option",'startupvalue');
- current=getoption("&option");
- if startup ne current then do;
- code =cat('OPTIONS ',getoption("&option",'keyword','startupvalue'),';');
- putlog "NOTE: Resetting system option: " code ;
- call execute(code );
- end;
-run;
-
+%if "%substr(&sysver,1,1)" ne "4" and "%substr(&sysver,1,1)" ne "5" %then %do;
+ data _null_;
+ length code $1500;
+ startup=getoption("&option",'startupvalue');
+ current=getoption("&option");
+ if startup ne current then do;
+ code =cat('OPTIONS ',getoption("&option",'keyword','startupvalue'),';');
+ putlog "NOTE: Resetting system option: " code ;
+ call execute(code );
+ end;
+ run;
+%end;
+%else %do;
+ %put &sysmacroname: reset option feature unavailable on &sysvlong;
+%end;
%mend mp_resetoption;/**
@file
@brief Generate and apply retained key values to a staging table