I am trying to merge two datesets, both containing the same subjects and dates but different visit event. One record, lb_sv, has a subject, date, and an event for that day such as Visit 1, Visit 2, Unscheduled Visit, and so on. The dataset lb_mrl is missing the visit event. That's what I want to get out of the merge but when I merge lb_mrl with lb_sv then I get a more than one error. I'm not too familiar with those errors although I imagine it means that there are multiple records with the same subject and date in both datasets. Does anyone know of a simple way I could solve this issue? What makes this problem interesting is that previously the in=a was on the dataset containing all of the desired variables (lb_sv). In the by statement of the merge, I had "by usubjid svstdtc unsflag etflag" and visits events populated for lb_mrl records. But when I switched in=a to the dataset lacking visit event (lb_mrl) the visit events did not merge. I just had a blanks in lb_sv_mrl for all of the records from lb_mrl. %getMappedStructure(lb,rawdata.MRL,lbd);
data LB_MRL;
length visdatc $200. svstdtc $19.;
set lbd;
USUBJID='MSP-2017-1158-'||MRLID;
if VISITLBL='Unscheduled Visit' then do;
unsflag='Y';
end;
if VISITLBL='Early Termination Visit' then do;
etflag='Y';
end;
visdatc=put(visitdt,mmddyy10.);
vistimc=put(visittm,tod5.);
%dtc(visdatc,,svstdtc);
drop visit visitnum;
run;
data lb_sv;
set sv;
if VISIT=:'Uns' then do;
unsflag='Y';
end;
if VISIT=:'Early' then do;
etflag='Y';
end;
drop epoch;
run;
proc sort data=lb_mrl;by USUBJID svstdtc;run;
proc sort data=lb_sv;by USUBJID svstdtc;run;
data lb_sv_mrl;
merge lb_mrl(in=a)
lb_sv;
by USUBJID svstdtc;
if a;
run;
proc freq data=lb_sv_mrl noprint;
tables USUBJID*svstdtc / out=chk(where=(count>1));
run;
proc print data=chk;
var USUBJID svstdtc;
run;
... View more