Data management syntax files
Here are some syntax files which will show you how to perform some common data management tasks, e.g., merging two files, matching information of respondent and their partner etc, using Understanding Society data files
Commonly-used commands to work with data.
Merging individual files across waves into wide format
To match individual level files across two waves into a wide format, do the following (for more waves add wave specific prefix in the foreach statement)
Merging individual files across waves into long format
To match individual level files across two waves into a long format, do the following (for more waves add wave specific prefix in the foreach statement)
Distributing household level information to the individual level
In this example we will distribute household level information to individuals in those households. We can do this by merging household level file (such as w_hhresp) with an individual level file (such as w_indresp) within the same Wave.
Summarising individual level information at the household level
In this example we will summarise individual level information within a household (number of 18-24-year-olds in the household) from an individual level file and then add it to the household level file.
Matching individuals within a household
In this example we will match the information of respondents living with partners/spouses with that of their partners/spouses.
Using the egoalt file to create household composition variables
In this example we will create a variable that measures the number of siblings in the household using the egoalt file. The resulting file can be merged with any individual level file.
Merging individual files from harmonised bhps and ukhls in long format
To match individual level files from the harmonised BHPS and Understanding Society in long format, you need to remove the wave prefixes in the two sets of files and generate a wave identifier that works across both sets of files. The pidp will work as the unique cross-wave identifier across both sets of files. This code only keeps individuals who took part in BHPS and drops those who joined as part of Understanding Society.