From 1672c96340763399bdf12778a7cdfb16c965e47d Mon Sep 17 00:00:00 2001 From: Allan Bowe Date: Tue, 10 May 2022 21:36:16 +0000 Subject: [PATCH] fix: testing fixes --- base/mp_filtercheck.sas | 7 ++--- base/mp_filtergenerate.sas | 3 +++ base/mp_hashdataset.sas | 6 ++++- ddl/mddl_dc_filterdetail.sas | 29 ++++++++++++--------- ddl/mddl_dc_filtersummary.sas | 17 +++++++----- ddl/mddl_dc_locktable.sas | 11 +++++--- tests/crossplatform/mp_filtercheck.test.sas | 2 +- 7 files changed, 48 insertions(+), 27 deletions(-) diff --git a/base/mp_filtercheck.sas b/base/mp_filtercheck.sas index c571297..c853496 100644 --- a/base/mp_filtercheck.sas +++ b/base/mp_filtercheck.sas @@ -95,8 +95,9 @@ data &outds; length reason_cd $4032 vtype $1 vnum dsid 8; /* get column attributes */ - if dsid=open("&inds","i")<1 then do; - REASON_CD="Unable to assign &inds"; + dsid=open("&targetds","i"); + if dsid<1 then do; + REASON_CD="Unable to assign &targetds"; putlog REASON_CD= dsid=; call symputx('reason_cd',reason_cd,'l'); call symputx('nobs',_n_,'l'); @@ -104,7 +105,7 @@ data &outds; end; vnum=varnum(dsid,VARIABLE_NM); if vnum<1 then do; - REASON_CD=cats("Variable (",VARIABLE_NM,") not found in &inds"); + REASON_CD=cats("Variable (",VARIABLE_NM,") not found in &targetds"); putlog REASON_CD= dsid=; call symputx('reason_cd',reason_cd,'l'); call symputx('nobs',_n_,'l'); diff --git a/base/mp_filtergenerate.sas b/base/mp_filtergenerate.sas index 3280460..7acac88 100644 --- a/base/mp_filtergenerate.sas +++ b/base/mp_filtergenerate.sas @@ -84,6 +84,9 @@ filename &outref temp; run; %end; %else %do; + proc sort data=&inds; + by SUBGROUP_ID; + run; data _null_; file &outref lrecl=32800; set &inds end=last; diff --git a/base/mp_hashdataset.sas b/base/mp_hashdataset.sas index c0ad40d..0cf88e8 100644 --- a/base/mp_hashdataset.sas +++ b/base/mp_hashdataset.sas @@ -69,7 +69,11 @@ %put %str(ERR)OR: Dataset &libds is not a dataset; %end; %else %do; - data &outds(rename=(&keyvar=hashkey) keep=&keyvar)/nonote2err; + data &outds(rename=(&keyvar=hashkey) keep=&keyvar) + %if "%substr(&sysver,1,1)" ne "4" and "%substr(&sysver,1,1)" ne "5" %then %do; + /nonote2err + %end; + ; length &prevkeyvar &keyvar $32; retain &prevkeyvar "%sysfunc(md5(%str(&salt)),$hex32.)"; set &libds end=&lastvar; diff --git a/ddl/mddl_dc_filterdetail.sas b/ddl/mddl_dc_filterdetail.sas index fa5e4a2..5349dd4 100644 --- a/ddl/mddl_dc_filterdetail.sas +++ b/ddl/mddl_dc_filterdetail.sas @@ -9,29 +9,32 @@ %macro mddl_dc_filterdetail(libds=WORK.FILTER_DETAIL); +%local nn lib; +%if "%substr(&sysver,1,1)" ne "4" and "%substr(&sysver,1,1)" ne "5" %then %do; + %let nn=not null; +%end; +%else %let nn=; + proc sql; create table &libds( - filter_hash char(32) not null, - filter_line num not null, - group_logic char(3) not null, - subgroup_logic char(3) not null, - subgroup_id num not null, - variable_nm varchar(32) not null, - operator_nm varchar(12) not null, - raw_value varchar(4000) not null, - processed_dttm num not null format=E8601DT26.6 + filter_hash char(32) &nn, + filter_line num &nn, + group_logic char(3) &nn, + subgroup_logic char(3) &nn, + subgroup_id num &nn, + variable_nm varchar(32) &nn, + operator_nm varchar(12) &nn, + raw_value varchar(4000) &nn, + processed_dttm num &nn format=E8601DT26.6 ); - %local lib; %let libds=%upcase(&libds); %if %index(&libds,.)=0 %then %let lib=WORK; %else %let lib=%scan(&libds,1,.); proc datasets lib=&lib noprint; modify %scan(&libds,-1,.); - index create - pk_mpe_filterdetail=(filter_hash filter_line) - /nomiss unique; + index create pk_mpe_filterdetail=(filter_hash filter_line)/nomiss unique; quit; %mend mddl_dc_filterdetail; \ No newline at end of file diff --git a/ddl/mddl_dc_filtersummary.sas b/ddl/mddl_dc_filtersummary.sas index 2e75c67..b295f5f 100644 --- a/ddl/mddl_dc_filtersummary.sas +++ b/ddl/mddl_dc_filtersummary.sas @@ -9,22 +9,27 @@ %macro mddl_dc_filtersummary(libds=WORK.FILTER_SUMMARY); +%local nn lib; +%if "%substr(&sysver,1,1)" ne "4" and "%substr(&sysver,1,1)" ne "5" %then %do; + %let nn=not null; +%end; +%else %let nn=; + proc sql; create table &libds( - filter_rk num not null, - filter_hash char(32) not null, - filter_table char(41) not null, - processed_dttm num not null format=E8601DT26.6 + filter_rk num &nn, + filter_hash char(32) &nn, + filter_table char(41) &nn, + processed_dttm num &nn format=E8601DT26.6 ); - %local lib; %let libds=%upcase(&libds); %if %index(&libds,.)=0 %then %let lib=WORK; %else %let lib=%scan(&libds,1,.); proc datasets lib=&lib noprint; modify %scan(&libds,-1,.); - index create= filter_rk /nomiss unique; + index create filter_rk /nomiss unique; quit; %mend mddl_dc_filtersummary; \ No newline at end of file diff --git a/ddl/mddl_dc_locktable.sas b/ddl/mddl_dc_locktable.sas index ca09140..da1fd0b 100644 --- a/ddl/mddl_dc_locktable.sas +++ b/ddl/mddl_dc_locktable.sas @@ -9,19 +9,24 @@ %macro mddl_dc_locktable(libds=WORK.LOCKTABLE); +%local nn lib; +%if "%substr(&sysver,1,1)" ne "4" and "%substr(&sysver,1,1)" ne "5" %then %do; + %let nn=not null; +%end; +%else %let nn=; + proc sql; create table &libds( lock_lib char(8), lock_ds char(32), - lock_status_cd char(10) not null, - lock_user_nm char(100) not null , + lock_status_cd char(10) &nn, + lock_user_nm char(100) &nn , lock_ref char(200), lock_pid char(10), lock_start_dttm num format=E8601DT26.6, lock_end_dttm num format=E8601DT26.6 ); - %local lib; %let libds=%upcase(&libds); %if %index(&libds,.)=0 %then %let lib=WORK; %else %let lib=%scan(&libds,1,.); diff --git a/tests/crossplatform/mp_filtercheck.test.sas b/tests/crossplatform/mp_filtercheck.test.sas index 49d5b04..fdb340c 100644 --- a/tests/crossplatform/mp_filtercheck.test.sas +++ b/tests/crossplatform/mp_filtercheck.test.sas @@ -174,7 +174,7 @@ run; outds=work.badrecords, abort=NO ) -%mp_assert(iftrue=(&syscc=42), +%mp_assert(iftrue=(&syscc=1008), desc=Throw error if RAW_VALUE is incorrect, outds=work.test_results )