Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: RE: RE: combine data by groups
From
"Martin Weiss" <[email protected]>
To
<[email protected]>
Subject
st: RE: RE: combine data by groups
Date
Wed, 3 Mar 2010 21:13:10 +0100
<>
"-collapse- to maxima."
In this _particular_ constellation, the minimum will serve Guang just as
well:
*******
clear*
inp str10 personid byte(parentsid momlive dadlive)
001 1 0 .
001 2 . 1
002 1 1 .
002 2 . 1
end
compress
list, noo
collapse (min) momlive dadlive, by(personid)
list, noo
*******
HTH
Martin
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Nick Cox
Sent: Mittwoch, 3. März 2010 21:06
To: [email protected]
Subject: st: RE: combine data by groups
-collapse- to maxima.
Advice: Don't flag questions as "easy".
Nick
[email protected]
G. Dai
hi all, this is an easy question,but somehow I can't figure it.
The data is like:
personid parentsid momlive dadlive
001 1 0
.
001 2 .
1
002 1 1
.
002 2 .
1
where personid and parentsid are person and her parents' id.
when parentid==1, we only record whether mom still live or not (momliv)
similarly
for parentid==2 and dadlive.
I want to change the data set to the following form
personid momlive dadlive
001 0 1
002 1 1
what is the best way to do this?
*
* 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/