I am trying to calculate the maximum daily dose in the last 7 days [t-7, t]. Each row has a dose and the respective day and I need a new column with the maximum value in the last seven days (that day inclusive). I can have situations where some days aren't available. Please see below the type of data I have and what I'm aiming for: data have; input id $ dose day; cards; A 1 1 A 1 2 A 1 3 A 1 4 A 1 5 A 2 6 A 2 7 A 3 8 A 1 9 ; run; data want; input id $ dose day max7days; cards; A 1 1 1 A 1 2 1 A 1 3 1 A 1 4 1 A 1 5 1 A 2 6 2 A 1 7 2 A 3 8 3 A 1 9 3 ; run; I'm fairly new SAS and would appreciate suggestions on the best method to perform this calculation. Please let me know if I should provide mor details so you can help me. Thanks in advance!
... View more