Is there an easy way (avoiding to calculate first the variables for the 6 column totals for each table one by one, then building the count for each category and dividing all this. And thus making the difference between such a variables) for obtaining such a table of those differences in Stata? I give you a dataset example below for if it helps.
Thanks in advance.
Code:
| x2 x1 | 1 2 3 4 5 6 | Total -----------+------------------------------------------------------------------+---------- 1 | 427 2,325 594 837 684 5 | 4,872 | 43.48 57.74 55.93 61.27 60.32 33.33 | 56.74 -----------+------------------------------------------------------------------+---------- 2 | 386 1,319 352 469 376 5 | 2,907 | 39.31 32.75 33.15 34.33 33.16 33.33 | 33.86 -----------+------------------------------------------------------------------+---------- 3 | 169 383 116 60 74 5 | 807 | 17.21 9.51 10.92 4.39 6.53 33.33 | 9.40 -----------+------------------------------------------------------------------+---------- Total | 982 4,027 1,062 1,366 1,134 15 | 8,586 | 100.00 100.00 100.00 100.00 100.00 100.00 | 100.00
Code:
| x2 x1 | 1 2 3 4 5 6 | Total -----------+------------------------------------------------------------------+---------- 1 | 363 2,927 614 964 851 5 | 5,724 | 50.21 63.92 60.37 60.02 63.18 35.71 | 61.64 -----------+------------------------------------------------------------------+---------- 2 | 279 1,339 344 590 435 6 | 2,993 | 38.59 29.24 33.82 36.74 32.29 42.86 | 32.23 -----------+------------------------------------------------------------------+---------- 3 | 81 313 59 52 61 3 | 569 | 11.20 6.84 5.80 3.24 4.53 21.43 | 6.13 -----------+------------------------------------------------------------------+---------- Total | 723 4,579 1,017 1,606 1,347 14 | 9,286 | 100.00 100.00 100.00 100.00 100.00 100.00 | 100.00
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(x1 x2 year) 2 1 2017 2 1 2020 1 5 2020 1 4 2020 1 4 2020 1 4 2020 1 1 2017 2 2 2017 1 3 2020 1 4 2020 3 4 2020 3 1 2020 1 5 2017 1 3 2020 . 3 2017 1 3 2017 1 4 2017 . 1 2017 2 3 2017 1 3 2017 3 2 2020 1 5 2017 3 1 2017 1 3 2020 1 5 2020 2 4 2020 2 4 2020 . 1 2017 2 4 2017 1 2 2020 1 4 2020 . 1 2020 2 5 2017 1 4 2020 1 3 2020 2 2 2020 1 4 2017 3 4 2020 3 3 2017 1 2 2017 1 5 2017 1 3 2020 . 1 2017 1 3 2017 3 1 2020 1 4 2020 1 4 2020 1 4 2020 1 4 2017 2 1 2020 1 5 2020 1 3 2017 1 3 2017 2 3 2017 1 2 2017 1 5 2017 2 3 2020 1 1 2017 1 4 2017 3 1 2017 2 2 2020 2 1 2017 1 5 2017 1 4 2020 end
0 Response to Extracting the column percentages from two tab
Post a Comment