1
0
mirror of https://github.com/sasjs/core.git synced 2025-12-10 14:04:36 +00:00

Merge pull request #243 from sasjs/resetoption

fix: resetoption
This commit is contained in:
Allan Bowe
2022-05-19 14:28:56 +03:00
committed by GitHub
3 changed files with 61 additions and 22 deletions

26
all.sas
View File

@@ -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

View File

@@ -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;

View File

@@ -0,0 +1,31 @@
/**
@file
@brief Testing mp_resetoption macro
<h4> SAS Macros </h4>
@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
)