| */*Example STATA program to create Unbalanced and Balanced Wide File |
| Created by: Alison Goode 27/09/06 (Updated by: Nicole Watson)*/ |
| */**********************************************************************************************************/ |
| */*Please note - uses all variables. If not all variables required, select and save as a separate file, |
| then proceed. |
| Please note: same variables for each consecutive wave NOT next to one another. To organise variables this way. If required, use the AORDER or ORDER command. |
| ***********************************************************************************************************/ |
| |
| set maxvar 15000 |
| |
|
| */Before merging the master file and combined files, sort xwaveid in each file and save each of them*/ |
| use "E:\Release 6.0\Masterfile_f60c.dta" |
| sort xwaveid |
| merge xwaveid using "E:\Release 6.0\Combined_a60c.dta" |
| sort xwaveid |
| drop _merge |
| merge xwaveid using "E:\Release 6.0\Combined_b60c.dta" |
| sort xwaveid |
| drop _merge |
| merge xwaveid using "E:\Release 6.0\Combined_c60c.dta" |
| sort xwaveid |
| drop _merge |
| merge xwaveid using "E:\Release 6.0\Combined_d60c.dta" |
| sort xwaveid |
| drop _merge |
| merge xwaveid using "E:\Release 6.0\Combined_e60c.dta" |
| sort xwaveid |
| drop _merge |
| merge xwaveid using "E:\Release 6.0\Combined_f60c.dta" |
| sort xwaveid |
| drop _merge |
| save "E:\Release 6.0\Wide-UNBALANCED_6waves.dta" |
| */*********************************************************************** |
| *Section 2: To convert to a balanced wide file |
| n==8864 |
| ***********************************************************************/ |
| use "E:\Release 6.0\Wide-UNBALANCED_6waves.dta" |
| sum afstatus bfstatus cfstatus dfstatus efstatus ffstatus |
| sort xwaveid |
| #delimit ; |
| by xwaveid:keep if (afstatus==1|afstatus==2)&(bfstatus==1|bfstatus==2)&(cfstatus==1|cfstatus==2)&(dfstatus==1|dfstatus==2) &(efstatus==1|efstatus==2)&(ffstatus==1|ffstatus==2); |
| #delimit cr |
| sum afstatus bfstatus cfstatus dfstatus efstatus ffstatus |
| save "E:\Release 6.0\Wide-BALANCED_6waves.dta" |
| drop _all |