Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: programming puzzle


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: programming puzzle
Date   Sun, 15 Oct 2006 18:03:49 +0100

If you create a pseudopatient who has -filldate- for 
the start of every quarter in your study period and
then -tsset- and -tsfill- every patient will have 
a grid of quarters within their observations. 

This is only part of the problem but may help. 

Nick 
n.j.cox@durham.ac.uk 

Jeph Herrin
 
> I'm hoping for some insight into a solution to the following
> programming problem.
> 
> For 170k patients (ID), I have the dates they filled prescriptions
> (-filldate-) and the number of -days- each prescription covers (eg,
> the number of daily pills):
> 
> ID    filldate  days
> 1      10JAN01   30
> 1      20FEB01   14
> 1      03MAR01   45
> 1      05MAY01   30
> .
> .
> 2       etc
> 2
> 2
> .
> .
> .
> 
> The problem is that I need to figure how many total -days- they
> are covered out of each 90 day quarter. So in the above, the first
> patient starts on 10JAN01, so the first 90 day quarter ends on
> 10APR01. That means I need to break the 3rd record (03MAR01) into
> two records, 38 days for the first quarter and 7 days for the second
> quarter. I have to do this for all four 90 day quarters starting
> 10JAN01, and I have to do for every patient (and they all have
> different start dates).
> 
> What I'd like to do is insert a new record at the start of each
> quarter UNLESS they already have a record for that date. Then
> the last -filldate- for each quarter would be split to form the
> new record.
> 
> However, all of my attempts end up looking hopelessly complex
> and hence unreliable, and as I so often discover elegant solutions
> on this list I thought I'd fish for one here. Any ideas would
> be welcome.

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



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