Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
oezguer.guererk@uni-erfurt.de |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: RE: RE: RE: Writing the value of a variable in another variable in a selective way |

Date |
Wed, 01 Jun 2011 13:39:00 +0200 |

I tried the code below, but it doesn't work. forval subject =1/20 { forval period =1/60 { local partner = partner[`subject'] replace partnerprofit = profit[`partner'] in `period' } } } Thank you very much again! Ozgur Nick Cox schrieb:

Tim is correct; thanks!Nickn.j.cox@durham.ac.ukMak, TimothyI think Nick meant:gen partnerprofit = profit[5] in 3But following this logic, and if your dataset is not large, you could do it in a loop, I think:gen partnerprofit = . forval i=1/`=c(N)' { local partnerid = partnerid[`i'] replace partnerprofit = profit[`partnerid'] in `i' }where I assume you have a partnerid variable which gives you the observation number of the partner.If your id's do not go in 1,2,3,...,n, however, you may need to do a bit more programming... and probably -merge- is the easiest.Nick CoxIf the problem is just this, the solution would begen partnerprofit = profit[5] in 13In general, think about a -merge-.On Behalf Of oezguer.guererk@uni-erfurt.deHow can I write the value of the variable called profit for e.g.,subject i as the value into another variable called "partnerprofit" ofanother subject j?For example: I am subject 3, my partner is subject 5; his profit is 13,now I would like to stata write in my "partnerprofit" the value 13.* * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

-- Dr. Özgür Gürerk Lst. für Mikroökonomie & Laboratorium für experimentelle Wirtschaftsforschung (eLab) Microeconomics & Laboratory for Experimental Economics (eLab)

Tel: +49 361 7374561 Fax: +49 361 7374569 www.uni-erfurt.de/elab -- * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**RE: st: RE: RE: RE: Writing the value of a variable in another variable in a selective way***From:*Nick Cox <n.j.cox@durham.ac.uk>

**References**:**st: RE: RE: RE: Writing the value of a variable in another variable in a selective way***From:*Nick Cox <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: RE: Missing data in mental health research: a practical approach using Stata** - Next by Date:
**RE: st: RE: RE: RE: Writing the value of a variable in another variable in a selective way** - Previous by thread:
**st: RE: RE: RE: Writing the value of a variable in another variable in a selective way** - Next by thread:
**RE: st: RE: RE: RE: Writing the value of a variable in another variable in a selective way** - Index(es):