Statalist The Stata Listserver


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

RE : st: Loop with forvalues ..


From   "Svend Juul" <SJ@SOCI.AU.DK>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE : st: Loop with forvalues ..
Date   Tue, 7 Nov 2006 08:50:11 +0100

Alvine wrote:

Thank you for your help, but the number of measurement is different from
patient to patient. So I need to get the maximum value of measurement:

egen max_mes=max(nb_mes)

And then use

 forvalues i=1/`max_mes' {

...
----------------------------------------------

No; -forvalues- needs a constant. If you know that
the patient with most measurements has 97 measurements,
the command is:
  forvalues i=2/97 {

For all patients this creates the variables diff2-diff97,
but for the patient with three measurements, diff4-diff92
have missing values. And that is how it should be.

Hope this helps
Svend

__________________________________________

Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000  Aarhus C, Denmark
Phone: +45 8942 6090
Home:  +45 8693 7796
Email: sj@soci.au.dk
__________________________________________ 

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