Tak Wai,
You stated your problem clearly and here is the solution.
forvalues i = 1/10 {
replace v`i' = y if w==`i'
}
Friedrich
--- Tak-wai Chau <[email protected]> wrote:
> First forget about the specific example I used before.
>
> Now we have variables V1, V2,..., V10.
> We have another variable W contains integer values between 1 and 10
> inclusively.
> We also have another variable Y contain numerical values.
> I want to set Vi=Y if W==i for that observation and let other Vs
> unchanged for that observations.
>
> So what can I do in this case?
>
> Hope this is clearer now.
>
> Thanks a lot!
>
> Friedrich Huebler wrote:
> > --- Tak-wai Chau <[email protected]> wrote:
> >> The key question I have in mind is whether we can, within a
> loop,
> >> update one of the variables, and which variable to update is
> >> according to the value taking by another variable. This value is
> >> different across observations.
> >
> > Yes, you can do that but your explanation is too vague. It is
> > difficult to help if you don't provide a clear rule for how
> values
> > should be replaced.
> >
> > Friedrich
____________________________________________________________________________________
Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
http://answers.yahoo.com/dir/?link=list&sid=396546091
*
* 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/