Created
October 27, 2016 21:33
-
-
Save rblissett/f5ffa3ca3579e6291d6fade4c05b1ec9 to your computer and use it in GitHub Desktop.
File for completing the conversion of NCES SAS school universe files to Stata. Should be preceded by ConvertCCDtoStata_School.R.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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