I noticed that when calculating weighted sums, tabstat and table wildly differ. Code to replicate:
And the results which are wildly differ (even the ratio in each level to the total):
Any idea what's going on here?
Code:
clear all sysuse auto tabstat mpg [aw=weight], s(sum) by(rep78) table rep78 [aw=weight], c(sum mpg) row
Code:
. tabstat mpg [aw=weight], s(sum) by(rep78) Summary for variables: mpg by categories of: rep78 (Repair Record 1978) rep78 sum 1 127980 2 501920 3 1850920 4 1049930 5 668530 Total 4199280 . table rep78 [aw=weight], c(sum mpg) row Repair Record 1978 sum(mpg) 1 41.28387 2 149.6593 3 561.0549 4 365.8293 5 287.8211 Total 1384.974
Any idea what's going on here?
Comment