Dear Statalisters,
I have a dataset of hospital admissions: admissions indexed by
"admitid", patients indexed by "ptid", hospitals indexed by "hospid".
+-------------------------------------------+
| doadmit admitid ptid hospid |
|-------------------------------------------|
1. | 21 Jun 91 160 007336 1 |
2. | 23 Jun 91 197 007695 1 |
3. | 28 Jun 91 419 126888 1 |
4. | 30 Jun 91 550 046134 1 |
5. | 02 Jul 91 696 015142 1 |
|-------------------------------------------|
6. | 03 Jul 91 771 035194 1 |
7. | 05 Jul 91 906 006762 1 |
8. | 06 Jul 91 989 114879 1 |
9. | 07 Jul 91 1040 010445 1 |
10. | 11 Jul 91 1328 035194 1 |
|-------------------------------------------|
11. | 12 Jul 91 1403 016055 1 |
12. | 12 Jul 91 1402 001565 1 |
13. | 15 Jul 91 1609 007721 1 |
14. | 16 Jul 91 1694 015450 1 |
15. | 18 Jul 91 1856 005970 1 |
|-------------------------------------------|
| etc... |
What I would like to do is this: for each patient-admission, calculate
the total number of admissions at that hospital in the prior 90 days.
On Sep 3 '03, Kristien Verheyen posted a message to the listserv
(subject: "Generating 'moving sum' variable") that had to do with
calculating moving sums, but my data are a little more complicated. My
first thought was to expand the data with dummy dates of admission and
generate moving sums by the prior 90 rows, but then I run into the
problem that some hospitals have multiple admissions on one day.
Does anyone have any suggestions?
Thank you.
Alex Tsai
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/