Want to select patients who had ONLY surgery as ONLY treatment.
If I understand you correctly, this is what you want
data have;
input Pt $ malignancy Treatment $;
datalines;
A 1 Chemo
A 1 Surgery
A 1 Radio
A 2 Surgery
B 1 Surgery
C 1 Surgery
C 1 Chemo
D 1 Surgery
;
proc sql;
create table want as
select * from have
group by Pt, malignancy
having sum(Treatment='Surgery')=n(Treatment);
quit;
Result:
Pt malignancy Treatment A 2 Surgery B 1 Surgery D 1 Surgery
Patient A has other treatments? Why is he in there?
If I understand you correctly, this is what you want
data have;
input Pt $ malignancy Treatment $;
datalines;
A 1 Chemo
A 1 Surgery
A 1 Radio
A 2 Surgery
B 1 Surgery
C 1 Surgery
C 1 Chemo
D 1 Surgery
;
proc sql;
create table want as
select * from have
group by Pt, malignancy
having sum(Treatment='Surgery')=n(Treatment);
quit;
Result:
Pt malignancy Treatment A 2 Surgery B 1 Surgery D 1 Surgery
Thank you so much! The solution worked perfectly, appreciate your help.
Pt A was there because that patient had only surgery for malignancy # 2. But, we can't select that patient for malignancy #1 because the patient had multiple treatments for malignancy 1..
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.