Ursina Kuhn and Oliver Lipps, FORS, Lausanne
Version August 2013
Content
Aim of this documentation ......................................................................................................... 2
1 Missing values in the SHP ................................................................................................. 2
2 Merge files .......................................................................................................................... 3
2.1 Illustration of data merge ........................................................................................... 3
2.2 Identifiers in the SHP ................................................................................................. 4
2.3 The Merge command in Stata .................................................................................... 5
2.4 Merging two files of the SHP ..................................................................................... 6
2.5 Merging many files of the SHP .................................................................................. 8
2.6 Exercises: merge files ................................................................................................. 9
3 Add information from other household members ............................................................ 10
3.1 Create a partner file with the merge command ........................................................ 11
3.2 Create a file with information of mothers and fathers ............................................. 13
3.3 Adding information of other household members with the bysort prefix ................ 14
3.4 Exercise: add information from other household members ..................................... 14
4 Creating long data files (person period files) ................................................................... 15
4.1 Wide and long data formats ..................................................................................... 15
4.2 Create a long file with the append command ........................................................... 16
4.3 Create a long file with the merge and reshape command......................................... 16
4.4 Exercise: creating a long file .................................................................................... 19
5 Working in the long file ................................................................................................... 19
5.1 The bysort prefix ...................................................................................................... 19
5.2 Working with lags .................................................................................................... 20
5.3 Exercises working in the long file ............................................................................ 21