Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: counting observations


From   Jurgen Sidgman <[email protected]>
To   [email protected]
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index