1
0
mirror of https://github.com/sasjs/core.git synced 2026-01-09 10:20:06 +00:00

Merge pull request #332 from sasjs/patches

fix: invalid macro variable in mp_lockanytable.sas
This commit is contained in:
Allan Bowe
2023-04-07 11:30:04 +01:00
committed by GitHub
5 changed files with 55 additions and 15 deletions

14
all.sas
View File

@@ -312,13 +312,17 @@ https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/baseplus.md#functionex
%local dsid rc; %local dsid rc;
%let dsid=%sysfunc(open(&libds,is)); %let dsid=%sysfunc(open(&libds,is));
%if &dsid=0 or %length(&var)=0 %then %do; %if &dsid=0 %then %do;
%put %sysfunc(sysmsg()); %put %sysfunc(sysmsg());
0 0
%end;
%else %if %length(&var)=0 %then %do;
0
%let rc=%sysfunc(close(&dsid));
%end; %end;
%else %do; %else %do;
%sysfunc(varnum(&dsid,&var)) %sysfunc(varnum(&dsid,&var))
%let rc=%sysfunc(close(&dsid)); %let rc=%sysfunc(close(&dsid));
%end; %end;
%mend mf_existvar; %mend mf_existvar;
@@ -10451,7 +10455,7 @@ run;
data _null_; data _null_;
putlog 'NOTE-' / 'NOTE-'; putlog 'NOTE-' / 'NOTE-';
putlog "NOTE- &sysmacroname: table locked, waiting "@; putlog "NOTE- &sysmacroname: table locked, waiting "@;
putlog "%sysfunc(sleep(&loop_inc)) seconds.. "; putlog "%sysfunc(sleep(&loop_secs)) seconds.. ";
putlog "NOTE- (iteration &x of &loops)"; putlog "NOTE- (iteration &x of &loops)";
putlog 'NOTE-' / 'NOTE-'; putlog 'NOTE-' / 'NOTE-';
run; run;

View File

@@ -25,13 +25,17 @@
%local dsid rc; %local dsid rc;
%let dsid=%sysfunc(open(&libds,is)); %let dsid=%sysfunc(open(&libds,is));
%if &dsid=0 or %length(&var)=0 %then %do; %if &dsid=0 %then %do;
%put %sysfunc(sysmsg()); %put %sysfunc(sysmsg());
0 0
%end;
%else %if %length(&var)=0 %then %do;
0
%let rc=%sysfunc(close(&dsid));
%end; %end;
%else %do; %else %do;
%sysfunc(varnum(&dsid,&var)) %sysfunc(varnum(&dsid,&var))
%let rc=%sysfunc(close(&dsid)); %let rc=%sysfunc(close(&dsid));
%end; %end;
%mend mf_existvar; %mend mf_existvar;

View File

@@ -167,7 +167,7 @@ run;
data _null_; data _null_;
putlog 'NOTE-' / 'NOTE-'; putlog 'NOTE-' / 'NOTE-';
putlog "NOTE- &sysmacroname: table locked, waiting "@; putlog "NOTE- &sysmacroname: table locked, waiting "@;
putlog "%sysfunc(sleep(&loop_inc)) seconds.. "; putlog "%sysfunc(sleep(&loop_secs)) seconds.. ";
putlog "NOTE- (iteration &x of &loops)"; putlog "NOTE- (iteration &x of &loops)";
putlog 'NOTE-' / 'NOTE-'; putlog 'NOTE-' / 'NOTE-';
run; run;

View File

@@ -17,4 +17,24 @@
%mp_assert( %mp_assert(
iftrue=(%mf_existvar(sashelp.class,isjustanumber)=0), iftrue=(%mf_existvar(sashelp.class,isjustanumber)=0),
desc=Checking non existing var does not exist desc=Checking non existing var does not exist
)
data work.lockcheck;
a=1;
output;
stop;
run;
%mp_assert(
iftrue=(%mf_existvar(work.lockcheck,)=0),
desc=Checking non-provided var does not exist
)
proc sql;
update work.lockcheck set a=2;
%mp_assert(
iftrue=(&syscc=0),
desc=Checking the lock was released,
outds=work.test_results
) )

View File

@@ -7,23 +7,35 @@
@li mp_assertcols.sas @li mp_assertcols.sas
@li mp_assertcolvals.sas @li mp_assertcolvals.sas
@li mp_assertdsobs.sas @li mp_assertdsobs.sas
@li mp_assertscope.sas
**/ **/
/* valid filter */ /* make some data */
%mp_getcols(sashelp.airline,outds=work.info) proc sql;
create table work.src(
SOME_DATETIME float format=datetime19.,
SOME_CHAR char(16),
SOME_NUM num,
SOME_TIME num format=time8.,
SOME_DATE num format=date9.
);
/* run macro, checking for scope leakage */
%mp_assertscope(SNAPSHOT)
%mp_getcols(work.src,outds=work.info)
%mp_assertscope(COMPARE)
%mp_assertdsobs(work.info, %mp_assertdsobs(work.info,
desc=Has 3 records, desc=Has 5 records,
test=EQUALS 3, test=EQUALS 5,
outds=work.test_results outds=work.test_results
) )
data work.check; data work.check;
length val $10; length val $10;
do val='NUMERIC','DATE','CHARACTER'; do val='NUMERIC','DATE','CHARACTER','DATETIME','TIME';
output; output;
end; end;
run; run;