cd "C:\DATA\masters theses\mitch reese\" set mem 2000m set more off log using merging.log, replace display "$$_DATE $$_TIME" /*This file is based on Mitch Reese's "working25(2nd).do" Currie and Moretti is up through 1996, this updates to 2000 The growing schools list was created by taking any schools w/ <200 students in 96 but 200+ in 2000 College reference books were used to make sure the schools should be included and to give the schools opening year info These files are seperately saved to be merged into C&M later School changes include those that grew in enrollment by enough to meet the 200 student threshold and be added, those that fell in enrollment enough to be dropped those that were a new school with enough enrollment to meet the threshhold */ *Following program will create running total of schools of different types to add to Currie and Moretti capture program drop sumcount program sumcount args changetype schooltype capture drop `changetype'`schooltype' sort fips yropen gen `changetype'`schooltype' = 0 local n = 1 forvalues state = 1(1)56 { local counter = 0 *display "new state `state'" if fips[`n'] == `state' { forvalues year = 1960(1)2000 { local counter = `counter' + `schooltype'[`n'] quietly replace `changetype'`schooltype' = `counter' if _n==`n' *display "`n' `counter' " local n = `n'+1 } } } end capture program drop cleanschools program cleanschools args filenm types cd "C:\DATA\masters theses\mitch reese\THESIS\DATA\COLLEGE OPENING DATA\DATA\mergingsets\" insheet using "`filenm'.txt", clear cd "C:\DATA\masters theses\mitch reese\" drop if yropen=="Drop" drop if yropen=="drop" drop if yropen=="DROP" drop if instnm== "missing" tab fouryear control capture destring yropen, replace replace yropen = 1960 if yropen<1960 gen twoyearpub = 1 if fouryear==0 & control ==1 gen twoyearpvt = 1 if fouryear==0 & (control ==2|control==3) gen fouryearpub = 1 if fouryear==1 & control ==1 gen fouryearpvt = 1 if fouryear==1 & (control ==2|control==3) collapse (sum) twoyearpub (sum) twoyearpvt (sum) fouryearpub (sum)fouryearpvt, by (fips yropen) sort fips yropen save "Stoddard\Data\temp", replace use "Stoddard\Data\liststates.dta" merge 1:1 fips yropen using "Stoddard\Data\temp.dta" display "merge liststateswith counts of schools ""`filenm'" drop _merge replace twoyearpub = 0 if twoyearpub==. replace fouryearpub = 0 if fouryearpub==. replace twoyearpvt = 0 if twoyearpvt==. replace fouryearpvt = 0 if fouryearpvt==. sumcount `types' twoyearpub /*calls program sumcount*/ sumcount `types' twoyearpvt /*calls program sumcount*/ sumcount `types' fouryearpub /*calls program sumcount*/ sumcount `types' fouryearpvt /*calls program sumcount*/ sort fips yropen merge 1:1 fips yropen using "Stoddard\Data\schoolchangetotals", update display "merge into totals ""`filenm'" drop _merge drop twoyearpub fouryearpub twoyearpvt fouryearpvt save "Stoddard\Data\schoolchangetotals", replace end use "THESIS\DATA\COLLEGE OPENING DATA\DATA\mergingsets\growin schools\liststates.dta", clear rename yearopen yropen sort fips yropen save "Stoddard\Data\liststates.dta", replace save "Stoddard\Data\schoolchangetotals", replace cleanschools growing grow cleanschools new new cleanschools shrinking shrink insheet using "THESIS\DATA\COLLEGE OPENING DATA\DATA\tribalsets\list.txt", clear *This is list of all tribal colleges*/ drop if eftotal<200 drop if eftotal==. capture destring yearopened, force replace drop if yearopened==. rename yearopened yropen /*First tribal college opens in 1968*/ /*Only 1 tribal college opens after 1996, enrollment is 141 students in 2000*/ gen twoyearpub = 1 if b4==1 gen twoyearpvt = 1 if b5==1 gen fouryearpub = 1 if a4==1 gen fouryearpvt = 1 if a5==1 drop a* b* eftotal collapse (sum) twoyearpub (sum) twoyearpvt (sum) fouryearpub (sum)fouryearpvt, by (fips yropen) sort fips yropen save "Stoddard\Data\temp", replace use "Stoddard\Data\liststates.dta" merge 1:1 fips yropen using "Stoddard\Data\temp.dta" display "merge liststateswith counts of schools ""`filenm'" drop _merge replace twoyearpub = 0 if twoyearpub==. replace fouryearpub = 0 if fouryearpub==. replace twoyearpvt = 0 if twoyearpvt==. replace fouryearpvt = 0 if fouryearpvt==. sumcount tribal twoyearpub /*calls program sumcount*/ sumcount tribal twoyearpvt /*calls program sumcount*/ sumcount tribal fouryearpub /*calls program sumcount*/ sumcount tribal fouryearpvt /*calls program sumcount*/ sort fips yropen merge 1:1 fips yropen using "Stoddard\Data\schoolchangetotals", update drop _merge drop twoyearpub fouryearpub twoyearpvt fouryearpvt rename yropen year rename fips stfips save "Stoddard\Data\schoolchangetotals", replace **************************Merge with C & M************************************************************* use "THESIS\DATA\COLLEGE OPENING DATA\DATA\raw opening data.dta", clear aorder gen stfips = int(fips/1000) rename yearat17 year sort stfips year collapse (sum)totalA1 (sum) totalA2 (sum) totalA3 (sum) totalA4 (sum) totalA5 /// (sum)totalB1 (sum) totalB2 (sum) totalB3 (sum) totalB4 (sum) totalB5 , by (stfips year) *Notes from Currie and Moretti * TOTALA1 = total number of 4 year colleges * A2 = drop if not in IPEDS list * A3 = drop if does not grant at least associate degree * A4 = drop if not public * A5 = drop if not private * TOTALB1-TOTALB5 are for 2 year colleges and are defined similarly. **In looking through this data, a number of observations **for A2 and A3, B2 and B3 seem to be zeros where years before and after are the same. sort stfips year foreach v of varlist totalA1-totalB5 { list stfips year if (`v'==0 & `v'[_n-1]~=0 & stfips==stfips[_n-1]) replace `v' = `v'[_n-1] if `v'==0 & `v'[_n-1]~=0 & stfips==stfips[_n-1] } **Wyoming also has 4 year schools missing--not sure Mitch actually corrected this sort stfips year merge 1:1 stfips year using "Stoddard\Data\schoolchangetotals" *DC is not in updated files drop _merge drop totalA1 totalA2 totalA3 totalB1 totalB2 totalB3 rename totalA4 fouryearpub rename totalA5 fouryearpvt rename totalB4 twoyearpub rename totalB5 twoyearpvt sort stfips year foreach v of varlist fouryearpub fouryearpvt twoyearpub twoyearpvt { foreach y of numlist 1997(1)2000 { replace `v' = `v'[_n-1] if year==`y' } replace `v' = `v' + new`v' + grow`v' - shrink`v' } replace fouryearpub = fouryearpub-tribalfouryearpub replace twoyearpub = twoyearpub-tribaltwoyearpub replace fouryearpvt = fouryearpvt - tribalfouryearpvt replace twoyearpvt = twoyearpvt - tribaltwoyearpvt sort stfips year save "Stoddard\Data\finalcollegecount" ****************************************Merge in state chars******************************** **Following data sets are generated by Mitch in "working25 (2nd).do" use "THESIS\DATA\CENSUS DATA\DATA\pop data\popfinal.dta", clear capture rename year year25 save, replace use "THESIS\DATA\CENSUS DATA\DATA\pop data\popna.dta", clear capture rename year year25 save, replace use "THESIS\DATA\CENSUS DATA\DATA\unemployment\unemployment.dta", clear capture rename year year25 save, replace use "THESIS\DATA\CENSUS DATA\DATA\urban\urban.dta", clear capture rename year year25 save, replace sort statefip year25 merge 1:1 statefip year25 using "THESIS\DATA\CENSUS DATA\DATA\pop data\popfinal.dta" drop _merge sort statefip year25 merge 1:1 statefip year25 using "THESIS\DATA\CENSUS DATA\DATA\pop data\popna.dta" drop _merge sort statefip year25 merge 1:1 statefip year25 using "THESIS\DATA\CENSUS DATA\DATA\unemployment\unemployment.dta" drop _merge save "Stoddard\Data\statelevelchars", replace rename year25 year rename statefip stfips sort stfips year merge 1:1 stfips year using "Stoddard\Data\finalcollegecount" drop _merge save "Stoddard\Data\statelevelchars", replace log close