全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
1711 2
2010-04-05
命令:shape long andshape wide 的区别和适用范围
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2010-4-5 23:06:15
. use "C:\Documents and Settings\ssbing\桌面\qq.dta"
. list
     +------------------------+
     | id    x1   x2   y1  y2 |
     |--------------------------|
  1. |  a   10   14    0    4 |
  2. |  b   11   15    1    5 |
  3. |  c   12   16    2    6 |
  4. |  d   13   17    3    7 |
     +-------------------------+

. reshape long x y,i(id)
(note: j = 1 2)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                        4   ->       8
Number of variables                   5   ->       4
j variable (2 values)                     ->   _j
xij variables:
                                  x1 x2   ->   x
                                  y1 y2   ->   y
-----------------------------------------------------------------------------

. list
     +------------------+
     | id    _j    x     y |
     |--------------------|
  1. |  a    1   10   0 |
  2. |  a    2   14   4 |
  3. |  b    1   11   1 |
  4. |  b    2   15   5 |
  5. |  c    1   12   2 |
     |--------------------|
  6. |  c    2   16   6 |
  7. |  d    1   13   3 |
  8. |  d    2   17   7 |
     +-------------------+

. reshape wide x y,i(id)
(note: j = 1 2)

Data                               long   ->   wide
-----------------------------------------------------------------------------
Number of obs.                        8   ->       4
Number of variables                   4   ->       5
j variable (2 values)                _j   ->   (dropped)
xij variables:
                                      x   ->   x1 x2
                                      y   ->   y1 y2
-----------------------------------------------------------------------------

. list
     +-------------------------+
     | id    x1    y1  x2   y2 |
     |---------------------------|
  1. |  a   10    0   14    4 |
  2. |  b   11    1   15    5 |
  3. |  c   12    2   16    6 |
  4. |  d   13    3   17    7 |
     +-------------------------+
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-4-6 18:35:34
非常感谢!!!!!!!!!!!!!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群