At present, I need to generate a new variable for each value in the variable called "setting" (Int 1-12), which would be the sum of those values if they also meet a condition of the variable "core"
The long form is below:
egen int Ava_core_Home = sum(count) if setting =="Home" & core == 1, by (P_num)
egen int Ava_core_Church = sum(count) if setting =="Church/church hall" & core == 1, by (P_num)
egen int Ava_core_Fale koloa = sum(count) if setting =="Church/church hall" & core == 1, by (P_num)
I tried something like:
forvalues i = 1/`i(setting)' {
egen int Ava_core_`i' =sum(count) if setting ==`i' & core == 1, by (P_num)
}
but keep getting syntax errors
Thank you for your help
The long form is below:
egen int Ava_core_Home = sum(count) if setting =="Home" & core == 1, by (P_num)
egen int Ava_core_Church = sum(count) if setting =="Church/church hall" & core == 1, by (P_num)
egen int Ava_core_Fale koloa = sum(count) if setting =="Church/church hall" & core == 1, by (P_num)
I tried something like:
forvalues i = 1/`i(setting)' {
egen int Ava_core_`i' =sum(count) if setting ==`i' & core == 1, by (P_num)
}
but keep getting syntax errors
Thank you for your help
Comment