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

st: referencing variables


From   [email protected]
To   [email protected]
Subject   st: referencing variables
Date   Thu, 9 Jan 2003 09:56:36 -0800

Hello,

I was wondering if anyone can help me on this programming problem.  I have
an array of variables, let's say x1-x20, and I wish to refer to one of them
using values in another variable (let's call it m), in an equation so that
I can use one equation that is different for each observation.  In other
words, if my equation is y = x`m' + 1 and m = 2, then the equation for that
particular observation would be y = x2 + 1.  Here is a partial list of what
I'm talking about:

obs    m      equation

1          2       y = x2 + 1
2          3       y = x3 + 1
3          6       y = x6 + 1
4          8       y = x8 + 1

I don't think using a global or macro variable works because those only
take on one value and because the equation is essentially the model in a
non-linear estimation, I don't think I could use a loop.  I was wondering
if there are more options out there.  Thank you!




Jackie Yuen


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index