我需要计算各州的高中教育百分比。但Stata 功能count不允许by选项。到目前为止,我有以下内容:
count
local totalPopulation = r(N )
count if schenr==0
local eduBelowHighSchool = r(N)
local _eduBelowHighSchool=`eduBelowHighSchool'/`totalPopulation'
count if schenr==1
local eduHighSchool = r(N )
local _eduHighSchool=`eduHighSchool'/`totalPopulation'
count if schenr==2
local eduCollege = r(N )
local _eduCollege=`eduCollege'/`totalPopulation'
gen eduBelowHighSchool =`_eduBelowHighSchool'
gen eduHighSchool =`_eduHighSchool'
gen eduCollege =`_eduCollege'
// 如何计算每个状态的单独值?我不能用count, by (state),可以吗?上面的代码生成下表:

有没有其他方法可以解决这个问题?