使用 PROC SQL 输出数据检查的特定结果

Outputting specific results from data check using PROC SQL

我有这个代码来检查 SDTM 中的正确基线实验室值。

/* Checking for no baseline results*/
proc sql;
create table dca as
select a.usubjid, a.lbtestcd,a.lbblfl,a.lbdy,a.lbstresn,b.good_value
from lb as a
left join
(select usubjid,lbtestcd,lbdy as good_value label='Baesline record' from lb
where lbdy < 0 group by usubjid, lbtestcd having lbdy= max(lbdy)) as b 
on a.usubjid = b.usubjid and a.lbtestcd = b.lbtestcd;

create table dcb as 
select unique 'LB' as domain,
compbl("USUBJID/lbblfl Subset") as key_grp_vr length = 50
, case when lbblfl='Y' and ^(lbdy=good_value) then 
'FAIL: At least one Baseline is Not correct'
else 'PASS: All Baselines are correct' end as dc_rslt label="Data Check Results for:" length =75
from dca
;
quit;

proc sort data=dca;
by usubjid lbtestcd lbdy;
run; 

proc print data=dcb; run;

DCA 使用 LEFT JOIN 和带有 WHERE 条件的子查询创建 GOOD_VALUE 来过滤记录。具有按摘要函数过滤的条件,GROUP BY.DCB 具有条件块以确认 LBBLFL 和 GOOD_VALUE。这是输出

因此,由于 DCB 同时显示通过和失败,这意味着至少有一个不正确的基线标记。虽然这很有用,但我想知道是否有某种方法可以创建另一个 table 来输出这种情况下的确切记录。有人对如何执行此操作有任何建议吗?

对相同的 DCB 和 return 值进行排序,但似乎您在 table 中也没有任何唯一标识符?

proc sort data=dcb;
by domain key_gpr_vr;
run;

data mismatched;
set dcb;
by domain key_grp_vr;
IF not(first.key_grp_vr and last.key_grp_vr);
run;