Hi @rajd1
Here is a way to achieve this.
Could you please clarify the rule to compute delay and reduction?
In the following program, I have set reduction and delay to "yes" if there was at least one record equal to "yes", and "none" in other cases.
However, I can see that there is a value "Other" for patient 2 at cycle 3. How would you like to handle this case?
Best,
proc sql;
select distinct ID, DrugName, MaxCycle, MinCycle, countdose, Avgdose, max(FirstDose) as FirstDose, max(LastDose) as LastDose, Delay, Reduction
from (select ID, DrugName,
max(cycle) as MaxCycle,
min(cycle) as MinCycle,
count(dose) as countdose,
mean(dose) as Avgdose format=8.1,
dose*(cycle=calculated MinCycle) as FirstDose,
dose*(cycle=calculated MaxCycle) as LastDose,
case when sum(lowcase(delay)="yes") > 1 then "yes" else "none" end as Delay,
case when sum(lowcase(reduction)="yes") > 1 then "yes" else "none" end as Reduction /*what if "Other" ?*/
from L_line1
group by ID, DrugName)
group by ID, DrugName
order by ID, DrugName;
quit;
... View more