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]

From |
Nick Cox <njcoxstata@gmail.com> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: data management problem |

Date |
Fri, 16 Dec 2011 14:17:11 +0000 |

There's an FAQ on such any and all problems. Nick

one way: use -egen- with the "max" function; here is an example: egen atleastone=max(dummy_member_is_pensioner), by(hh_id) Rich On 12/16/11 8:44 AM, Ivica Rubil wrote:Dear StatalistersI have the first four variables in the table below in my dataset,and Iwish to generate the fifth variable. This variable should be suchthatit is equal to 1 for all members of a particular household if thereisat least one pensioner in this household. Below is the table withonlytwo households one of which contains at least one pensioner and Iwishto assign 1 to each member of this household. The other householddoesn't contain any pensioner and I wish to assign 0 to each memberofthis household. How to do that??? hh_id | hh_member | dummy_member_is_pensioner | dummy_hh_with_at_least_one_pensioner------|-------------|----------------------------|-------------------------------------- 1 | 1 | 1 | 1 1 | 2 | 1 | 1 1 | 3 | 0 | 1 1 | 4 | 0 | 1 2 | 1 | 0 | 0 2 | 2 | 0 | 0 2 | 3 | 0 | 0 ... | ... | ... | ...

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

**Follow-Ups**:**Re: st: data management problem***From:*Nick Cox <njcoxstata@gmail.com>

**References**:**st: Testing for mediation with categorical mediators and complex survey data?***From:*"Galinsky, Adena M." <agalinsk@jhsph.edu>

**Re: st: Testing for mediation with categorical mediators and complex survey data?***From:*John Antonakis <John.Antonakis@unil.ch>

**st: data management problem***From:*"Ivica Rubil" <irubil@eizg.hr>

**Re: st: data management problem***From:*Richard Goldstein <richgold@ix.netcom.com>

- Prev by Date:
**Re: st: data management problem** - Next by Date:
**Re: st: RE: data management problem** - Previous by thread:
**Re: st: data management problem** - Next by thread:
**Re: st: data management problem** - Index(es):