Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: counting observations


From   Jurgen Sidgman <sidgman@uwm.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: counting observations
Date   Wed, 29 Dec 2010 18:32:41 -0600

Hi,

I have a dataset that has observations for each day of many months. What I need to do is: for each month I need to add all observations for each of the previous 3 months. For example, for january I need to add all observations from October to December from the previous year. Next, for february I need to add all observations from November to January and so on. What I have been doing so far is calculating the cumulative value for each month as follows:

. sort obsdate
. egen count_obs = count(obsdate) if year(obsdate) == 2004 & month(obsdate) <= 3 (this is for the first time I perform the calculation)



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index