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

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

st: Create Variable containing Generations per Household

From   Laura Marlene Große <>
Subject   st: Create Variable containing Generations per Household
Date   Wed, 19 Sep 2012 16:11:28 +0200

Hello Stata community,
I have a dataset comprising a few houndred households and about 3,000 individuals that I've collected last year. One of my criteria to draw a random subsample for my future research will be how many generations do live in one household. Using my variable "relation to the head of the household" i have identified the different types of relatives and their inter-generational position. Including my codes for rel_head that makes 5 possible generations:
1 (6 Parent, 7 Parent in law, 12 Uncle/Aunt)
2 (1 Head, 2 Conjugal Partner, 8 Biological Brother or Sister, 14 Cousin, 21 Sister/Brother in law, 23 Son in laws mother) 3 (3 Biological Son or Daughter, 4 Son/Daughter in law, 9 Adopted/Foster/Stepchild, 18 Late husbands nephew, 19 Nephew/Niece, 20 Wife's cousin's daughter, 22 Son in laws brother, 25 Stepson, 13 Brothers daughters husband) 4 (5 Grandchild, 15 Granddaughters boyfriend, 16 Grandsnephew/Grandniece, 24 Step daughters daughter)
5 (17 Great-grandchild)
In my individual based dataset (individual and household ID's), I would like to create a new variable which contains the number of generations per household. So it would be 1 generation if only number 2 is present, 2 generations if numbers 1 and 2 or 2 and 3 are present in the household and so on. I assume that I will have to write a loop using foreach or similar. However, I'm confused as to how to tell Stata to limit the loop to the specific households?!
I would very much appreciate your help!


Laura Marlene Große

Research Fellow Macroeconomics
Philipps University Marburg

*   For searches and help try:

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