Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

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

From |
"Mak, Timothy" <timothy.mak07@imperial.ac.uk> |

To |
"'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu> |

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

Date |
Tue, 31 May 2011 17:32:44 +0000 |

I think Nick meant: gen partnerprofit = profit[5] in 3 But 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. Tim -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox Sent: 31 May 2011 17:31 To: 'statalist@hsphsun2.harvard.edu' Subject: st: RE: Writing the value of a variable in another variable in a selective way If the problem is just this, the solution would be gen partnerprofit = profit[5] in 13 In general, think about a -merge-. Nick n.j.cox@durham.ac.uk -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of oezguer.guererk@uni-erfurt.de Sent: 31 May 2011 17:20 To: statalist@hsphsun2.harvard.edu Subject: st: Writing the value of a variable in another variable in a selective way Hello, How can I write the value of the variable called profit for e.g., subject i as the value into another variable called "partnerprofit" of another 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. Thank you very much for your help! Ozgur -- Dr. Özgür Gürerk Lehrstuhl für Mikroökonomie & Laboratorium für experimentelle Wirtschaftsforschung (Microeconomics & Laboratory for Experimental Economics) Universität Erfurt, Nordhäuser Str. 63, D-99089 Erfurt 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/ * * 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/ * * 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/

**References**:**st: Writing the value of a variable in another variable in a selective way***From:*oezguer.guererk@uni-erfurt.de

**st: 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: gllamm option geqs** - Next by Date:
**st: hosmer lemshow goodness of fit statistics** - Previous by thread:
**st: RE: Writing the value of a variable in another variable in a selective way** - Next by thread:
**st: gllamm option geqs** - Index(es):