Dear all
I am using the PALMS dataset (Post-Apartheid Labour Market Survey) - it is a stacked crossed sectional dataset of the labour market dynamic survey in South Africa (and its predecessors) across the years 1994 to 2017. It is at the individual level.
I am wanting to create a variable for the number of children in the household under the ages of 7 (i.e. 'Young children present'). I gather you do this using the 'egen' command. There is a variable for the household and individual identifier.
The code that i have tried to run is:
egen Y_CHILD = count(personnr) if age <= 7 , by (uqnr)
* Counts number of young children in every uqnr (household identifier)
egen YChild = max (YCHILD), by (uqnr)
*Assigns total number of children to each individual within the same household
tab YChild
recode YChild (0/2=1 "1. 0 - 2 children") (3/4=2 "2. 3 - 4 children") (5/6=3 "3. 5 - 6 children") (7/max=4 "4. 7 or more children"), gen(YChild_cat)
label var YChild_cat "Categorical variable: Number of Young Children present in Household"
*Assess years
tab YChild_cat if year == 2007
tab YChild_cat if year == 2012
tab YChild_cat if year == 2017
However, this does not produce the desired result. I believe i am missing something fundamental about the egen command.
Could anyone help?
Related Posts with Number of children in household variable from individual level dataset
Questions regarding Modelling both Sample Selection Bias and Endogenous Treatment BiasDear Statalist, Hi. This is the first time I post questions on the forum. I apologize if my post is…
Creating indicator variables from multiple categorical variableHello, I wanted to create an indicator variable combining two or more categorical variable. So for …
looping n times, and n is determined by another equationHello, I wish to loop n times, say: forvalues i = 1(1)n{ and n is defined by the last number of i…
Time-series regression with varying independent variables over timeDear forum, I am new to this forum and want to ask for your opinion on a time-series regression (20…
FmmHi, I have an FMM model with three class. Because the dv is binary, logistic regression is used. Le…
Subscribe to:
Post Comments (Atom)
0 Response to Number of children in household variable from individual level dataset
Post a Comment