Skip to content

Instantly share code, notes, and snippets.

@rblissett
Created October 27, 2016 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rblissett/f5ffa3ca3579e6291d6fade4c05b1ec9 to your computer and use it in GitHub Desktop.
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.
/* 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