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: summarize conditions within subjects in panel data


From   "Hoffman, George" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: summarize conditions within subjects in panel data
Date   Mon, 29 Nov 2010 11:56:48 -0600

I've got a panel dataset (xt) uniquely identified by subject (id)  and time (hour), sorted by id hour.
I'd like to generate a variable that counts the cumulative (within id, across hour) number of hours that a variable is less than 50.
My code so far:

gen varxl50 = varx <50 if varx <.
bysort patnum (hour): gen varxl50sum = sum(varxl50)

I'm running into problems because of missing values I think.
Does this code look right?
Is there a mode succinct way to code this?

Thanks in advance
George Hoffman


*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index