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..
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.