Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | owner-statalist@hsphsun2.harvard.edu |
To | statalist@hsphsun2.harvard.edu |
Subject | st: From: António S.P. <slanton7@gmail.com> |
Date | Thu, 15 Jul 2010 17:43:31 +0100 |
Hi all, I think this is a very basic loop. I need to get the values of NMEV (number of EV’s per month (here without the “.”) for every 27th day of each month (between 1980 and 1995, 6100 obs.). I have moving sums of counts for last week, last month, etc., but I need a “static” sum also and doing that manually is a little painful and absurd. In this case, I have 0 in my first 27th day but as EV_s moves along (it sums occurrences) it behaves as a moving sum. Due to the fact that I have longitudinal data, I prefer to count each monthly value of NMEV over t than over DATE, for further analysis. I would greatly appreciate, too, if someone tells me how to count those zeros or peace spells between EV==1’s for the whole period and how to deal with the 256 cases in which I have more than one value for EV on the same day (14 Feb 80 in my sample, for example). Note that my “t” records two consecutive values for that date, a complication that I would like to avoid without having NA´s in that variable. Thanks in advance, António EV EV_s t NMEV DATE 0 0 1 01 Jan 80 0 0 2 02 Jan 80 0 0 3 03 Jan 80 0 0 4 04 Jan 80 0 0 5 05 Jan 80 0 0 6 06 Jan 80 0 0 7 07 Jan 80 0 0 8 08 Jan 80 0 0 9 09 Jan 80 0 0 10 10 Jan 80 0 0 11 11 Jan 80 0 0 12 12 Jan 80 0 0 13 13 Jan 80 0 0 14 14 Jan 80 0 0 15 15 Jan 80 0 0 16 16 Jan 80 0 0 17 17 Jan 80 0 0 18 18 Jan 80 0 0 19 19 Jan 80 0 0 20 20 Jan 80 0 0 21 21 Jan 80 0 0 22 22 Jan 80 0 0 23 23 Jan 80 0 0 24 24 Jan 80 0 0 25 25 Jan 80 0 0 26 26 Jan 80 0 0 27 27 Jan 80 0 0 28 28 Jan 80 0 0 29 29 Jan 80 0 0 30 30 Jan 80 0 0 31 31 Jan 80 0 0 32 01 Feb 80 0 0 33 02 Feb 80 0 0 34 03 Feb 80 0 0 35 04 Feb 80 0 0 36 05 Feb 80 0 0 37 06 Feb 80 0 0 38 07 Feb 80 0 0 39 08 Feb 80 0 0 40 09 Feb 80 0 0 41 10 Feb 80 1 1 42 11 Feb 80 1 2 43 12 Feb 80 0 2 44 13 Feb 80 1 3 45 14 Feb 80 1 4 46 14 Feb 80 1 6 48 15 Feb 80 1 5 47 15 Feb 80 0 6 49 16 Feb 80 * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/