全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
1524 0
2010-09-09
我新学stata有很多地方不了解 希望各位大侠帮忙解答一下 先感谢一下

id     date     newcycle cyclenum
311 1997-06-01     1      1
311 1997-06-22     0      1
311 1997-07-14     0      1
311 1998-09-17     1      2
311 1998-10-08     0      2
311 1998-12-07     2      3
311 1999-02-07     0      3
432 1997-11-04     2      1

数据是上面这个样子  
newcycle是指病人开始新的循环 每个循环开始用1或者2表示不固定用哪个 如果是0就还停留在上一个循环中
我想创建出cyclenum这个变量
这个变量是指明这个病人现在处于哪个循环中 比newcycle更清晰明了
这个变量该怎么创建?

老师给了我一些hints 但是我还是不太理解
Hint 1: sort the data on id, and within id, the date
Hint 2: make a new, temporary, variable that stores a 1 if the observation is a newcycle and 0 if not.
           Use the correct function AND you operate within each  stratum as defined by the id

到底该用哪个函数啊?
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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