Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
File for completing the conversion of NCES SAS school universe files to Stata. Should be preceded by ConvertCCDtoStata_School.R.
/* ConvertCCDtoStata_School.do
Richard Blissett (rsl.bliss@gmail.com)
Finally processes data produced from ConvertCCDtoStata_School.R
*/
* Environment settings
set more off
clear all
* Basic information
cd "~/Documents/CCD Data/School"
local firstyear = 2001
local lastyear = 2014
* Decode and compress data from R
forvalues year = `firstyear'/`lastyear' {
* Open file
use "ROutput/ccdSch_`year'", clear
* Loop through each variable
qui ds *
foreach var in `r(varlist)' {
* Get variable information
gen junk = `var'
order junk, after(`var')
local varlab : variable label `var'
* Decode labeled data
capture decode `var', g(junk2)
capture replace junk = junk2
capture drop junk2
* Re-create variable
drop `var'
rename junk `var'
label var `var' "`varlab'"
}
* Compress data
compress
* Save file
save "ConvertedFiles/ccdSch_`year'", replace
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment