SDTM visit 与visitnum

方法一:
思路是用proc sql 办法将2种情况下的sdtm.sv与源数据进行匹配,从而抓取现成的VISITNUM与VISIT;
proc sql noprint;
  create table pe as 
    select t1.*,t2.visitnum,t2.visit as sdtm_visit,
     t3.visit as nvisit length=200,t3.VISITNUM as visitnumn from raw.pe(where=(PEPERF ne ' ') drop=visitnum) as t1
    left join mdata.sv as t2
    on 'cats(t1.usubjid)=t2.usubjid and (not index(t1.visit,"计划外访视") and t1.visit=t2.visit  
    or index(t1.visit,"计划外访视") and  index(t2.visit,"计划外访视") and t2.svstdtc=t1.pedat)
   left join mdata.tv as t3
    on upcase(t1.visit)=upcase(t3.visit);
quit;

方法二:直接和现成visit_mapping进行匹配,重新进行visit 和 visitnum的二次编辑,形如:
data sv2;
    set sv1;
    _STUDYID=STUDYID;
    _DOMAIN='SV';
    _USUBJID=strip(studyid)||'-'||strip(usubjid);
    if index(visit,"计划外") then id=100;
run;

data tv;
    set sdtmsub.tv;
run;

proc sql noprint;
    create table sv3 as
    select a.*,b.visit as visit1,b.visitnum as visitnum1 from sv2 as a
    left join tv as b
    on a.visit=b.visit;
quit;

proc sort data=sv3 out=sv4 nodup;
by usubjid visdat id;
run;

data sv5;
 set sv4;
 by usubjid;
 retain visit_r ;
 if first.usubjid then visit_r=visitnum1;

 if missing(visitnum1) then visitnum1=visit_r+0.01;
 visit_r=visitnum1;
run;

data sv6;
     set sv5;
 by usubjid;
 retain ttt;
 if first.usubjid then ttt=visit1;

 if missing(visit1) then visit1=ttt;
 ttt=visit1;
run;

data sv7;
    set sv6;
    if index(visit,"计划外") and not missing(visit1)  then visit1=strip(visit1)||' '||'计划外访视'||' '||strip(__STUDYEVENTREPEATKEY);
    _visitnum=visitnum1;
    _visit=visit1;
    if missing(visdat) then delete;
run;



全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务