我有以下data集(这是一个小子集)。
这是我的代码:
reshape wide generalfund student_body_fund debt_fund capital_fund transport_fund, ///
i(district) j(header) string
我得到以下输出:
(note: j = Begin. T. Fund Balance End T. Fund Balance Excess levies Net Excess Levy O. Fin
> ance--G.L. 535 O. Finance--Transfer out Over/Under Expend Rollback Total Appropriation T
> otal Revenues)
(note: no data for header == Begin.)
(note: no data for header == T.)
(note: no data for header == Fund)
(note: no data for header == Balance)
(note: no data for header == End)
(note: no data for header == T.)
(note: no data for header == Fund)
(note: no data for header == Balance)
(note: no data for header == Excess)
(note: no data for header == levies)
(note: no data for header == Net)
(note: no data for header == Excess)
(note: no data for header == Levy)
(note: no data for header == O.)
(note: no data for header == Finance--G.L.)
(note: no data for header == 535)
(note: no data for header == O.)
(note: no data for header == Finance--Transfer)
(note: no data for header == out)
(note: no data for header == Over/Under)
(note: no data for header == Expend)
(note: no data for header == Total)
(note: no data for header == Appropriation)
(note: no data for header == Total)
(note: no data for header == Revenues)
Data long -> wide
-----------------------------------------------------------------------------
Number of obs. 2950 -> 295
Number of variables 8 -> 7
j variable (1 values) header -> (dropped)
xij variables:
generalfund -> generalfundRollback
student_body_fund -> student_body_fundRollback
debt_fund -> debt_fundRollback
capital_fund -> capital_fundRollback
transport_fund -> transport_fundRollback
-----------------------------------------------------------------------------
为什么说标题没有数据?我认为header=="Total Revenues"
和header=="Rollback"
之间没有区别,这是唯一重塑的价值。
有没有人有任何见解?我更喜欢Stata的答案,但我正在努力学习R,所以看到这两者都做得非常有帮助。