Skip to content

Commit

Permalink
feat: adding filtervar option to mp_stripdiffs
Browse files Browse the repository at this point in the history
  • Loading branch information
^ committed Apr 30, 2024
1 parent 22f0cb6 commit 862b189
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 7 additions & 4 deletions all.sas
Original file line number Diff line number Diff line change
Expand Up @@ -13407,6 +13407,8 @@ run;
change, plus ALL SUBSEQUENT CHANGES, will be reverted in the output table.
@param [in] difftable The dataset containing the diffs. Definition available
in mddl_dc_difftable.sas
@param [in] filtervar= (0) If provided, the contents of this macro variable
will be applied as an additional filter against &libds
@param [out] outds= (work.mp_stripdiffs) Output table containing the diffs.
Has the same format as the base datset, plus a
`_____DELETE__THIS__RECORD_____` variable.
Expand Down Expand Up @@ -13434,6 +13436,7 @@ run;
%macro mp_stripdiffs(libds
,loadref
,difftable
,filtervar=0
,outds=work.mp_stripdiffs
,mdebug=0
)/*/STORE SOURCE*/;
Expand All @@ -13457,11 +13460,11 @@ run;
,msg=%str(Invalid library.dataset reference - %superq(libds))
)



/* set up unique and temporary vars */
%local ds1 ds2 ds3 ds4 ds5 fref1;
%local ds1 ds2 ds3 ds4 ds5 fref1 filterstr;
%let fref1=%mf_getuniquefileref();
%if &filtervar ne 0 %then %let filterstr=%superq(&filtervar);
%else %let filterstr=%str(1=1);

/* get timestamp of the diff to be reverted */
%local ts;
Expand Down Expand Up @@ -13546,7 +13549,7 @@ create table &outds as select "No " as _____DELETE__THIS__RECORD_____
,b.%scan(&notpkcols,&x,%str( ))
%end;
from &ds5 a
left join &libds b
left join &libds (where=(&filterstr)) b
on 1=1
%do x=1 %to %sysfunc(countw(&pk,%str( )));
and a.%scan(&pk,&x,%str( ))=b.%scan(&pk,&x,%str( ))
Expand Down
11 changes: 7 additions & 4 deletions base/mp_stripdiffs.sas
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
change, plus ALL SUBSEQUENT CHANGES, will be reverted in the output table.
@param [in] difftable The dataset containing the diffs. Definition available
in mddl_dc_difftable.sas
@param [in] filtervar= (0) If provided, the contents of this macro variable
will be applied as an additional filter against &libds
@param [out] outds= (work.mp_stripdiffs) Output table containing the diffs.
Has the same format as the base datset, plus a
`_____DELETE__THIS__RECORD_____` variable.
Expand Down Expand Up @@ -49,6 +51,7 @@
%macro mp_stripdiffs(libds
,loadref
,difftable
,filtervar=0
,outds=work.mp_stripdiffs
,mdebug=0
)/*/STORE SOURCE*/;
Expand All @@ -72,11 +75,11 @@
,msg=%str(Invalid library.dataset reference - %superq(libds))
)



/* set up unique and temporary vars */
%local ds1 ds2 ds3 ds4 ds5 fref1;
%local ds1 ds2 ds3 ds4 ds5 fref1 filterstr;
%let fref1=%mf_getuniquefileref();
%if &filtervar ne 0 %then %let filterstr=%superq(&filtervar);
%else %let filterstr=%str(1=1);

/* get timestamp of the diff to be reverted */
%local ts;
Expand Down Expand Up @@ -161,7 +164,7 @@ create table &outds as select "No " as _____DELETE__THIS__RECORD_____
,b.%scan(&notpkcols,&x,%str( ))
%end;
from &ds5 a
left join &libds b
left join &libds (where=(&filterstr)) b
on 1=1
%do x=1 %to %sysfunc(countw(&pk,%str( )));
and a.%scan(&pk,&x,%str( ))=b.%scan(&pk,&x,%str( ))
Expand Down

0 comments on commit 862b189

Please sign in to comment.