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

st: Data Processing; How to swap around observations?


From   [email protected]
To   [email protected]
Subject   st: Data Processing; How to swap around observations?
Date   Thu, 6 Nov 2003 17:07:30 -0000 (GMT)

Dear Stata Users

I have the following data set containing information on the level of
schooling (s) for every memeber (memid) of the household unit of reference
(hhid). In my case, I am looking at married couples. There are multiple
couples who reside in the same hhid. The variable "pairs" identifies how
many couples live within the same hhid. Please note that my "sex" and
"memid" variables are not sorted and they can't be sorted. This is an
inherent nature of the data.Head of the household can have any "memid" and
so can his/her spouse.  Hence, my data is organised in the following
manner:

hhid	memid	sex	s	pairs	smale	sfemale
1	1	female	8	1	0	8
1	2	male	3	1	3	0
2	1	male	12	2	12	0
2	2	female	10	2	0	10
2	4	female	15	2	0	15
2	8	male	10	2	10	0

What I have to do seems easy to achieve. I have to replace schooling of
the male (smale) with the schooling of the female (sfemale) taking into
account the nature of the data set.

This is the expected format:

hhid	memid	sex	s	pairs	smale*	sfemale*
1	1	female	8	1	3	0
1	2	male	3	1	0	8
2	1	male	12	2	10	0
2	2	female	10	2	0	12
2	4	female	15	2	15	0
2	8	male	10	2	0	10

One can use an "egen" command if there was only one pair per houeshold
(sum the schooling level of the male and the female respondents and then
substract and subsitute). Multiple hhid's are problematic.I was unable to
account for them. I tried to reshape the data from "long" to "wide" to no
avail: the fact that "sex" and "memid" do not follow an appropriate order
creates problems.

I hope that you could possible suggest a way to solve this.

Thank you.

Altay Mussurov
PhD (c)
University of Wales Aberystwyth










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