Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: subscripts for loop?

From   Jesper Sorensen <[email protected]>
To   [email protected]
Subject   Re: st: subscripts for loop?
Date   Wed, 31 Mar 2004 19:23:09 -0500

It's not clear what you want to do with the variables, but this loop will _display_ them, just make arbitrary changes within the inner loops.

forvalues i=1(1)18 {
if `i'<10 {
di b0_0`i'
else {
di b0_`i'

I'm stumped on a programming problem. I need to refer to a sequence of variables b0_01, b0_02, b0_03 . . . b0_18, where the subscript identifies an individual child of a given
woman and the first part of the variable refers to some characteristic of
that child. (The woman is the unit of observation, and for each woman
there are up to 18 children observed.) My idea was to do a loop with j=1,
then j = j+1, etc., referring to b0_j. But this won't work. My boyfriend
suggested doing the j loop and then concatenating to b0_, but I can't
find anything in stata on how to concatenate a number to a string.
Does anyone have any ideas?

Thanks for your help!

* For searches and help try:
*   For searches and help try:

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