Código Stata para datos mexicanos

Age in MxFLS-1 | Edad en la ENNVIH-1

Contributing user: Florian Chávez Juárez

Database: ENNVIH

Keywords age, edad, ennvih, mxfls

Explanation: Calcula la edad de la persona para la base de datos ENNVIH1. Requiere el libro c_ls

use c:/data/ennvih/c_ls  //adapt this path to find the correct file on your computer

** Age
  gen age=ls02_2    
  sum age if ls02_1==2
  replace age=age/12 if ls02_1==2   // age indicated in month
  replace age=age/365 if ls02_1==3  // age indicated in days
  replace age=. if ls02_1==8
  replace age=0 if age<1
  replace age=2002-ls03_22 if age==.
  label variable age "Age in years"
              

ENNVIH: Género | MxFLS: Gender

Contributing user: Florian Chávez Juárez

Database: ENNVIH

Keywords gender, ennvih, female, male, género

Explanation: Una manera sencilla de generar una variable dummy que toma el valor de 1 para mujeres y 0 para hombres. Automáticamente genera el 'label' correcto. Requiere la base 'c_ls' This code defines a new variable gender with labels, taking the value of 1 for women and 0 for men. The code must be applied to the database 'c_ls'

** Gender
recode ls04 (1=0 "Male")(3=1 "Female"), gen(gender)
label variable gender "Dummy for gender (1=women)"

ENNVIH: identificar padre/madre | MXFLS: identify parents

Contributing user: Florian

Database: ENNVIH

Keywords father, mother, padre, madre, tutor, relationship, family structure

Explanation: This code allows you to create an ID of the father and the mother of each individual. Additionally a variable with the ID of the tutor (if the parents are not in charge) is created. It requires the database c_ls

** LOAD THE c_ls.dta data before running this code

** Father
rename ls06 id_father
replace id_father=-1 if id_father==51
label variable id_father "Identificator (ls) of the father"

** Mother
rename ls07 id_mother
replace id_mother=-1 if id_mother==51
label variable id_mother "Identificator (ls) of the mother"

** Tutor
rename ls08 id_tutor
gen nocare=id_tutor==52
recode id_tutor (99 51=.)
replace nocare=. if id_tutor==.
replace id_tutor=ls if id_tutor==52   // own id, since cares about itself
label variable nocare "Child cares about itself (no tutor)"
label variable id_tutor "Identificator (ls) of person that care about child"
              

Actualmente SobreMéxico.mx cuenta con:

26 artículos de Revista Sobre México 494 publicaciones 16 Working Papers 43 autores 30 bases de datos 3 códigos y 7 programas 2 congresos y seminarios 2 materiales didácticos