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, statalist.org is already up and running.


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

Re: st: RE: combine data by groups


From   "G. Dai" <dgecon@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: combine data by groups
Date   Wed, 3 Mar 2010 12:10:26 -0800

that is great. thank you, Martin!
G.

On Wed, Mar 3, 2010 at 12:05 PM, Martin Weiss <martin.weiss1@gmx.de> wrote:

>
> <>
>
> *******
> 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 (firstnm) momlive dadlive, by(personid)
> list, noo
> *******
>
>
> HTH
> Martin
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of G. Dai
> Sent: Mittwoch, 3. März 2010 20:40
> To: statalist@hsphsun2.harvard.edu
> Subject: st: combine data by groups
>
> 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?
>
> thanks,
> Guang
>
> *
> *   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/
>
*
*   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/


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