For years I've used workarounds to handle the following type of problem. I've decided finally to appeal to the collective wisdom of the StataList community.
Suppose I have variables named y01, ..., y99. I wish to manipulate each in the same manner, possibly in a forval loop.
does not work, as might be expected, since y01-y09 are treated as if they are named y1-y9 in the sum command.
Might anyone suggest an elegant way to handle this? The solution would ideally generalize to y001-y999, etc.
Note: Ideally I would like to avoid using
since variables other than y01-y99 might get caught in the y01-y99 varlist. But if this is the best way to proceed then so be it and I presume that something like
would suffice.
Thanks in advance.
Suppose I have variables named y01, ..., y99. I wish to manipulate each in the same manner, possibly in a forval loop.
Code:
forval j=01/99 {
sum y`j'
}
Might anyone suggest an elegant way to handle this? The solution would ideally generalize to y001-y999, etc.
Note: Ideally I would like to avoid using
Code:
foreach z of varlist y01-y99 {
Code:
preserve
order ..., alpha
foreach ... {
...
}
restore
Thanks in advance.

Comment