I need to calculate the percentage of high school education by states. But Stata function count
does not allow by
option. So far I have the following:
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'
// How can I calculate individual values for each state? I cannot use count, by (state)
, can I? The above code produces the following table:
Is there any other way to work around this issue?