Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: merging variables within groups


From   [email protected]
To   [email protected]
Subject   st: merging variables within groups
Date   Tue, 27 May 2003 00:58:24 -0400 (EDT)

Hello,

I have a dataset which includes three variables as follows:


var	1	2	3	

hhd1	a	n	o
hhd1	b	o	.

hhd2	c	p	r
hhd2	d	q	.
hhd2	e	r	.

hhd3	f	s	o
hhd3	g	o	.
.
.
.
.


that is, variable 2 and 3 share common values (like an id variable), with
some missing values for variable 3.  i would like to create a fourth variable
which gives the value for variable 1 (originally in the same row as the
observation variable 2) in the same row as the observation for variable 3: 

 
	
var	1	2	3	4

hhd1	a	n	o	b
hhd1	b	o	.	.

hhd2	c	p	r	e
hhd2	d	q	.	.
hhd2	e	r	.	.

hhd3	f	s	o	g
hhd3	g	o	.	.


but since the common 'id' variable may be the same for different individuals
across households, i also wanted to correct for that when matching columns 3
and 2 (so that 'g' does not get matched to household 1 instead of household
3).  is there a way to join these two functions together in Stata?

Thank you very much,

Gayatri Koolwal

*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index