Dear Statalist community,

I am an inexperienced coder new to Stata, who is trying to replicate and extend an existing paper. The first step is to calculate the share of the middle class for a number of countries and time periods using the LIS database. The definition of the middle class that I am using is households with an income between 75 percent and 125 percent of the median household income. In order to make households comparable, I'm using the OECD household equivalence scale (the oxford scale): 1.0 to the first adult; 0.7 to the second and each subsequent person aged 14 and over and 0.5 to each child aged under 14. However, so far I haven't managed to get the same numbers as the authors of the other paper and I'm not sure if I'm taking the right steps.

use dhi nhhmem13 nhhmem hpopwgt using $ca91h
sum dhi [w=hpopwgt*nhhmem], de
gen edhi = dhi/(1+(0.7*nhhmem-1-nhhmem13)+0.5*nhhmem13)
sum edhi [w=hpopwgt*nhhmem], de
gen weight = hpopwgt*nhhmem
sum weight if edhi >= .75*r(p50) & edhi <= 1.25*r(p50)
display r(sum)
Above is the code, where:
dhi = disposable household income
hpopwgt = household weight
nhhmem = number of household members
nhhmem13 = number of household members 13 or younger
$ca91h = indicates that it is Canada 1994

So how do I retrieve the middle class share from this information, I thought I could perhaps simply divide the sum of the weights fulfilling the if-criteria with the sum of weights given when summarizing the equivalized household income (without if-criteria)? Is that how you would go about this or am I missing some essential step?