BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
khalidamin
Obsidian | Level 7

Capture.PNG
Want to select patients who had ONLY surgery as ONLY treatment.

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Super User

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 

View solution in original post

3 REPLIES 3
PeterClemmensen
Super User

Patient A has other treatments? Why is he in there?

PeterClemmensen
Super User

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 
khalidamin
Obsidian | Level 7

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..

SAS INNOVATE 2024

Innovate_SAS_Blue.png

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. 

Register now!

What is Bayesian Analysis?

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 401 views
  • 1 like
  • 2 in conversation