```Date: Fri, 22 Jun 2012 06:30:34 -0400 Reply-To: Rick Wicklin Sender: "SAS(r) Discussion" From: Rick Wicklin Subject: Compute a running total I was recently asked the following questions: Suppose you have data that consists of N integer values in the range [1, 120], which represent months for which events occurred over a 10-year period. (One observation indicates one event.) The question is: what is an efficient way to compute the 24-month period during which the most events occurred? For concreteness, assume the data are as follows: data Events; keep y; call streaminit(1); do i = 1 to 50; y = ceil(120*rand("Uniform")); /* random in [1,120] */ output; end; run; A discussion and a SAS/IML program that solves the problems are available on my blog: http://blogs.sas.com/content/iml/2012/06/22/compute-a-running- total/ or short URL http://bit.ly/LlahTi My question: This must be a classic problem that has been solved dozens of times on this list. What is the consensus for the most efficient way to solve this problem? Thanks, Rick Wicklin Statistical programming and SAS/IML blog: http://blogs.sas.com/content/iml ```

Back to: Top of message | Previous page | Main SAS-L page