This is a python tool for the German Standardization Panel (www.normungspanel.de) that automates panel data preparation for data collected in several survey waves (with potentially changing variable names, question scales, participants & participant-affiliations, etc.):
The script performs the following steps:
- Unify variable names
- Map question scales
- Transform yearly data into long format (with variable "year")
- Identify participants in project database, find yearly affiliations
- Select ideal representative for companies (avoid duplicate entries)
- Create data structure (info sheet, data dictionary, yearly data, panel data)
- Output as Excel-file
The inputs for this script are:
settings/settings.json: Main settings for running the script, e.g., paths to other input files, which years to include in output, rules for missing data, etc.- panel (default:
settings/panel.xlsx): Excel file that includesdata dictionary: variable names, variable aliases, variable properties, associated scalescales: data value aliases that are converted in script's step 2- participant/company database (DB tables
persons,panel_entities,companies,groupsas sheets) selections: history of participants selected for past samples, to be able to reproduce results
- survey results (default: Excel files
survey-results/results_yyyy.xlsx)
The output is an Excel file (default: output/dnp_panel-data_<year_panel_starts>-<year_panel_ends>_<file_creation_date>.xlsx) that includes several sheets:
- info: creation date, number of observations
- variables: variable overview (name, label, question, scale)
- scales: available data values per question scale
- panel yyyy-yyyy: panel data in long format with variable
year - yyyy: one sheet of data per year
See comments in settings/settings.json.
Set up the configuration by editing settings/settings.json and then run using the run.cmd or python create_dataset.py.