hi, i want to find the % of students that are included in treated and control groups based on the results and the % is from the sample size of each schools. i was wondering if there's any command to help me find the % of T and % of C from student sample on each schools?
************************
** 1. Non-compliance **
************************
*Keep needed variables non non-compliance table
keep school_id treatment_el ece_fr_cycles
duplicates drop
* Store the number of schools that completed 0-5 cycles of FR
replace ece_fr_cycles = 0 if missing(ece_fr_cycles) //replace the ECE cycle variable with 0 if data is missing
forval c = 0/5{
count if ece_fr_cycles == `c' & treatment_el == 1
local treat`c' `r(N)'
count if ece_fr_cycles == `c' & treatment_el == 0
local control`c' `r(N)'
}
* % students
???
*Import the endline datasum
use `el_data', clear
replace ece_fr_cycles = 0 if missing(ece_fr_cycles)
* Set up table variables
gen FRcycles = .
gen Treat_assigned_schools = .
gen Treat_assigned_students = .
gen Control_assigned_schools = .
gen Control_assigned_students = .
local i 1
* Input values in the variables
forval c = 0/5{
count if treatment_el == 0
local total_c `r(N)'
replace FRcycles = `c' in `i'
replace Treat_assigned_schools = `treat`c'' in `i'
count if treatment_el == 1
local total_t `r(N)'
count if ece_fr_cycles == `c' & treatment_el == 1
replace Treat_assigned_students = `r(N)'/`total_t' in `i'
replace Control_assigned_schools = `control`c'' in `i'
count if treatment_el == 0
local total_c `r(N)'
count if ece_fr_cycles == `c' & treatment_el == 0
replace Control_assigned_students = `r(N)'/`total_c' in `i'
local++i
}
* Export table
export excel FRcycles-Control_assigned_students using "${output}/Graphs and Tables/Non-compliance.xlsx", replace firstrow(variable)
************************
** 1. Non-compliance **
************************
*Keep needed variables non non-compliance table
keep school_id treatment_el ece_fr_cycles
duplicates drop
* Store the number of schools that completed 0-5 cycles of FR
replace ece_fr_cycles = 0 if missing(ece_fr_cycles) //replace the ECE cycle variable with 0 if data is missing
forval c = 0/5{
count if ece_fr_cycles == `c' & treatment_el == 1
local treat`c' `r(N)'
count if ece_fr_cycles == `c' & treatment_el == 0
local control`c' `r(N)'
}
* % students
???
*Import the endline datasum
use `el_data', clear
replace ece_fr_cycles = 0 if missing(ece_fr_cycles)
* Set up table variables
gen FRcycles = .
gen Treat_assigned_schools = .
gen Treat_assigned_students = .
gen Control_assigned_schools = .
gen Control_assigned_students = .
local i 1
* Input values in the variables
forval c = 0/5{
count if treatment_el == 0
local total_c `r(N)'
replace FRcycles = `c' in `i'
replace Treat_assigned_schools = `treat`c'' in `i'
count if treatment_el == 1
local total_t `r(N)'
count if ece_fr_cycles == `c' & treatment_el == 1
replace Treat_assigned_students = `r(N)'/`total_t' in `i'
replace Control_assigned_schools = `control`c'' in `i'
count if treatment_el == 0
local total_c `r(N)'
count if ece_fr_cycles == `c' & treatment_el == 0
replace Control_assigned_students = `r(N)'/`total_c' in `i'
local++i
}
* Export table
export excel FRcycles-Control_assigned_students using "${output}/Graphs and Tables/Non-compliance.xlsx", replace firstrow(variable)
Comment