Hi ,
i have a scenario to
Output If the Site or Subject or Visit number or Visit Date is either present in the "A" data set but is missing from the "B" data set or vice versa?
any suggestions will be helpful, Thanks.
As @Vijay77 asked for: "...present in the "A" data set but is missing from the "B" data set or vice versa?"
a light change need to last step of @Jagadishkatam :
data want;
merge dataset_a(in=a) dataset_b(in=b);
by site subject visit_number visit_date;
if not (a and b); /* line changed */
run;
You can use the merge statement with by group to output such records or else you can also use the proc sql joins.
An example data would help to get better inputs.
Hi,
consider these as a example data
A B
site subject Visit number Visit Date site subject Visit number Visit Date
101 123 10 12aug2019 101 123 15 12aug2019 *here visit number diff so i should get as missing visnumber
101 134 05 14aug2019 101 134 05 . *here output missing date from b
101 135 09 . 101 135 09 14aug2019 *here output missing date from a
please try the below code
proc sort data=dataset_a;
by site subject visit_number visit_date;
run;
proc sort data=dataset_b;
by site subject visit_number visit_date;
run;
data want;
merge dataset_a(in=a) dataset_b(in=b);
by site subject visit_number visit_date;
if b and not a;
run;
As @Vijay77 asked for: "...present in the "A" data set but is missing from the "B" data set or vice versa?"
a light change need to last step of @Jagadishkatam :
data want;
merge dataset_a(in=a) dataset_b(in=b);
by site subject visit_number visit_date;
if not (a and b); /* line changed */
run;
Yes. of course. The checking is done after merging.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.