Hi,
I am working with firm-level data (cross-section data). I am trying to calculate the weighted sum of product Gross Value by (i) Product Code (given by productASICC) and (ii) State
I am using collapse command as follows:
(i) For Weighted Sum by Product Code
collapse (sum) sum_output=productGrossValue [aw=emult2] , by(productASICC)
(ii) For Weighted Sum by State
collapse (sum) sum_output=productGrossValue [aw=emult2], by(state)
However, when I collapse the two (separately) and then calculate the total of sum_output, I get a different answer in each case!
Total Sum (when doing (i))= 7956141480645.23
Total Sum (when doing(ii))=5334065631590.61
Please let me know if I am doing anything wrong! My gut is that, the two sums should be equal. But I dont know if my code is incorrect or not.
Thanks
Dhruv
Related Posts with Weighted Sum in Collapse
How to avoid changing directory every time?I am using two devices, every time that I want to open the do file that I developed on the other dev…
Cannot paste table ( pasted as picture) from Stata output to excel?Dear all, I am now trying to copy and paste from the Stata output table to excel. I use 'copy as a …
How to design a correct twoway scatter graph?Good morning to the community. I would like to design a graph like this:Array But I would like fir…
Bootstrapping s.e. with country FEs - Two-stage estimation with fractional logit in second stage.Hi, I am running a two stage regression, where the first stage is a linear regression of a price in…
Interaction termHi Everyone! I try to run a regression with an interaction variable in Stata. The interaction term …
Subscribe to:
Post Comments (Atom)
0 Response to Weighted Sum in Collapse
Post a Comment