Hi -
I have a longitudinal data set in long form with annual obs
for 6 years on 1450 kids. I am trying to create a cumulative variable
such that the
value for age 10 is the sum of the values at age 9 and age 10, the value
for age 11 is
the sum of the value for 9, 10, & 11 and so on. I can figure out
how to do this in wide form, but I am going to have to repeat it for
about 50
different variables. It would be much easier if I could just keep the
data in long form. I experimented with _n, and by id age, but
couldn't get what I wanted (e.g., for age 11 I could get the sum of age
10 (_n-1) and
age 11, but not age 9, 10, &11).
Once I create this new variable, is there an easy way to repeat the same
thing for 50 different variables? I usually just copy and paste in my do
file, changing
variable names, but lately the do files have gotten rather long. It seems
there is probably an easy way to have it do the same thing over and over
for
different variables, but I can't figure it out.
Thank you in advance for any suggestions...
Sarah
Sarah Mustillo, Ph.D
Center for Developmental Epidemiology
Department of Psychiatry and Behavioral Sciences
Duke University Medical Center
*
* 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/