Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | "Martin Weiss" <martin.weiss1@gmx.de> |
To | <statalist@hsphsun2.harvard.edu> |
Subject | st: AW: Creating variables with values taken from other observations |
Date | Tue, 10 Aug 2010 14:42:19 +0200 |
<> Have you tried the Stata FAQ, e.g. http://www.stata.com/support/faqs/data/setobsequal.html ? HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Mark McCann Gesendet: Dienstag, 10. August 2010 14:37 An: statalist@hsphsun2.harvard.edu Betreff: st: Creating variables with values taken from other observations Hello folks, I've worked out a way to do this using excel, but I'd much prefer to keep everything in Stata instead of jumping back and forward every time I generate a variable along these lines. My data has three variables Respondent ID - Friend ID - Respondent Characteristic The best friend ids all correspond to another respondent's ID. I want to create a variable - best friend's characteristic. For each observation I want to take that observation's friend ID, find the observation that has this friend id value as its value for respondent ID, read this observation's characteristic value and create a new variable taking the characteristic's value for the original observation. Question again in table format because I know that description wasn't very clear I have data like this Rid Fid Gender 1 2 Female 2 5 Male 5 7 Missing . . . . . . How do I create this? Rid Fid Gender Fgender 1 2 Female Male 2 5 Male Missing 5 7 Missing etc. . . . . . . . . Is there a way to do this in Stata? I used gender as a reader-friendly example however I will be using predominantly numeric coding. Many thanks, Mark McCann Research Statistician Improving Children's Lives Institute of Child Care Research Queen's University Belfast 6 College Park Belfast BT7 1LP Tel: +44(0)28 9097 3163 Improvingchildrenslives.org * * 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/