I have the following data set. I am writing two separate SQL steps to count the subjects with different conditions. Is there way to combine both the queries into one using SQL sub-queries. Any kind of input on this is appreciated.
data have;
input sub TEAE $ trt $;
cards;
101 N A
101 Y A
101 Y A
101 N A
102 Y B
103 N B
104 N A
104 Y A
104 Y A
104 N A
;;
proc sql;
create table totevents as select trt,count (sub) as events
from have
where teae eq 'Y'
group by trt;
quit;
proc sql;
create table totsubs as select trt,count (distinct sub) as subs
from have
group by trt;
quit;