Statalist


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

st: count with a loop


From   LY Pierrem <lypierrem@yahoo.fr>
To   statalist@hsphsun2.harvard.edu
Subject   st: count with a loop
Date   Wed, 16 Dec 2009 08:15:46 +0000 (GMT)

Dear Stata list,

I have a data set that looks like this

personid             dateposted                    datefunded
    1             2009-04-04  3:20:08            2009-04-04  10:00:14
    2                                 
                          

I am trying to create a new variable, which for each person n, would
count the number of people such that 1. they were posted before person
n AND 2. were funded after person n was posted. In other words, this would count the number of people active (i.e. posted but not yet funded) on the database at the time each person n is posted.

It seems that a simple egen and conditional count are not good enough for the purpose.

Is a loop necessary for this? I have an idea that a loop is needed here
(maybe using forval?) but any help would be greatly appreciated! 

Thanks for any suggestions!
Pierre


      

*
*   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/



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