02-06-2015 12:11 AM
This is my data set(Table 1).I need to get the output from this table(Table 1)
I would like to get below table(table 2)(Based on subject how many test is assigned for particular treatment) .I need to get the count of each event in each column(subject for 1 event etc.)
|Treatment||N||total event||subject for 1 event||subject for 2 event||subject for >=3 event|
N= total no of distinct subject
total event = total no of distinct event
Subject for 1 event (count of at least one event under treatment)
Subject for 2 event (count of at least two event under treatment)
Subject for 3 event (count of at least >=3 event under treatment)
Message was edited by: Krishna chandran
02-06-2015 01:01 AM
Why can't you include your code? There shouldn't be anything confidential in your code.
I'm not following your example to be honest, so I don't know what your output should look like. Can you fill in the boxes to help explain the logic?
02-06-2015 02:46 AM
You need to post what output you need according to your sample data .
data have; input subject : $20. treatment $ event $ ; cards; Usubjid_01 A X Usubjid_01 A Y Usubjid_01 B X Usubjid_02 B Y Usubjid_02 B Z Usubjid_03 A X Usubjid_03 B Y ; run; proc sql; create table want as select treatment,sum(n=1) as Subject_for_1_event,sum(n=2) as Subject_for_2_event,sum(n=3) as Subject_for_3_event from (select treatment,subject,count(*) as n from have group by treatment,subject) group by treatment; quit;