/*--------------------------------------------------- ex1rep.do Analyses exemplar 1 with replication methods YOU WILL NEED ONE OF THE LARGER VERSIONS OF Stata (SE or INTERCOOLED) to run this exemplar HOW TO USE THIS FILE To submit commands highlight the line you want to submit and go to >Do on the >Tools menu The results will then appear in the main Stata window Any text between a /* and a */ is treated as a comment. At the Stata command window typing "help do" will give more information and "help help" gives very useful information on viewing results first get the simple mean and confidence interval of the income (unweighted) First step is to install the svr library You need to be connected to the internet for this and it will take a few minutes, but you only need to do it once. ------------------------------------------------------------------------------------------------------*/ ssc install svr /*-------------------------------------------------------------------------------------------------------- When it installs you can use the help for the commands for svr to find out about it If you have already opened the data set by clicking on the web page you should save it (file menu >save) empty the workspace with the command drop _all You need to do this before you increase the memory to run this analysis ------------------------------------------------------------------------------------------------------*/ set matsize 800 set memory 1g /*--------- now reopen your saved data file----------------------- first changing directory to whee your file is located ---------------------------------------------------------------------------------------*/ cd "C:\Documents and Settings\gillian raab\My Documents\aprojects\peas\web\exemp1\data" use ex1,clear /*----------------------------------------------------------------------------------------------- the next bit of code adds the sum of the weights by council tax band and tenure type so they can be used to rake the sample to match both of these --------------------------------------------------------------------------------------------------*/ collapse (sum) cttot=weight, by (ctband) /* make data file with totals*/ sort ctband save cttots,replace /* sort and save it*/ use ex1,clear sort ctband /* get original file and sort by ctband*/ merge ctband using cttots /*----------merge with totals and save--------------*/ save ex1,replace collapse (sum) cttot=weight, by (tentype) /* make data file with totals*/ sort tentype save tentots,replace /* sort and save it*/ use ex1,clear drop _merge sort tentype /* get original file and sort by ctband*/ merge tentype using cttots /*----------merge with totals and save--------------*/ save ex1,replace use ex1,clear collapse (sum) cttot=weight, by (tentype) save tentots use ex1,clear sort cttots merge use "C:\Documents and Settings\gillian raab\My Documents\aprojects\peas\web\exemp1\data\ex1.dta" ,clear /*------------------- ------------------------------------------------------------------ and make a set of jacknife weights for this survey This next command will create 481 new variables (one for each replicate) where one of the 481 PSUs is dropped from each replication. Look at the data to check this ----------------------------------------------------------------------------------------------------------*/ survwgt create jk1, psu(psu) weight(weight) /*---------------- now use the survey replication commands--------------------------------*/ collapse (sum) cttot=weight, by (ctband)