# Re: st: RE: coding problem: looping through a list of ID's

 From "Leny Mathew" To statalist@hsphsun2.harvard.edu Subject Re: st: RE: coding problem: looping through a list of ID's Date Mon, 24 Nov 2008 14:45:51 -0500

```Thanks Nick & Jeff for your suggestions. I think that I was perhaps
not clear enough with what I was trying to do. The following is the
data for one of the patients:

pt_id         dov	          pt_ht	   age
2	       	24-May-01  141  	  12.92519
2	       	31-May-01	 141	          12.94441
2	       	11-Sep-01	 141	          13.22718
2	       	11-Dec-01	 145	          13.47701
2	      	21-Feb-02	 146	          13.67467
2	      	2-May-02	 147	          13.86685
2	     	11-Jul-02	 149	          14.05903
2	     	21-Nov-02	 152	          14.42416
2	     	21-Jan-03	 152.3	  14.59163
2	     	10-Apr-03	 153.7	 14.80851
2	     	1-May-03	 153.4	 14.86616
2	     	1-Jul-03	 153.8	 15.03363
2	     	9-Sep-03	 154.8	 15.22581
2	     	18-Nov-03	 154.8	 15.41798
2	     	20-Jan-04	 156	         15.59094
2	     	18-Mar-04	 157	         15.75017
2	     	20-May-04	 156	         15.92313
2	     	15-Jul-04	 157	         16.07687
2	     	16-Sep-04	 157	          16.24983
2	     	11-Nov-04	 158	          16.40357

I'm trying to find out how much this patient grew in a year. So the
way I thought of it is to find out the interval of time that
approximates an year and then compute the difference in height between
those two points. So, taking the difference between _n and _n-1 will
not suffice but it has to be _n and _n-i when i goes from 1 to _N
within patient.
For example the first time point is 24 May 01 and the time that
approximates a year is 2 may 02. So, the height increase would be
(147-141).
Then the next one would be from 2 May 02 to 1 May 03 and so on.
The patient number 3 has 105 visits from 1988 to 2000, so the number
of intervals would be more compared to ID 2. I would most probably end
up using the most recent one year height increase for analysis
purposes, but that doesn't make this any easier.

I hope this clarifies things better.

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