Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

st: AW: Creating variables with values taken from other observations

From   "Martin Weiss" <>
To   <>
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. ?


-----Ursprüngliche Nachricht-----
[] Im Auftrag von Mark McCann
Gesendet: Dienstag, 10. August 2010 14:37
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

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

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index