全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
4439 8
2010-04-03
在fortran中很容易实现的求累积和,怎样在stata中实现?

即,本期累加教育年限 = 前期教育累加年限+本期参加教育与否



fortran code example (仅仅表达上述问题意思,code本身极有可能是错误的)

do 1 t=1/10
   acedu_t=acedu_t-1 + edu_t
1 continue


感谢任何建议
二维码

扫码加我 拉你入群

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

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

全部回复
2010-4-3 07:23:05
*对x求累积和
g s=sum(x)
二维码

扫码加我 拉你入群

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

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

2010-4-6 05:58:17
thanks. the sum() gives the total but not accumulative sum for each period.

here is the right code

gen byte acedu1=edu1
forvalue i=2/17 {
  local j=`i'-1
  gen byte acedu`i'=edu`i'+acedu`j'
}
二维码

扫码加我 拉你入群

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

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

2010-4-8 18:30:00
feelinginwind 发表于 2010-4-6 05:58 thanks. the sum() gives the total but not accumulative sum for each period.
really?

(g x=sum(y))
二维码

扫码加我 拉你入群

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

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

2010-4-8 22:51:28
for a long data, use sum() has to control the id for longitudinal data. how to control the id here?
二维码

扫码加我 拉你入群

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

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

2010-4-9 00:42:24
feelinginwind 发表于 2010-4-8 22:51 for a long data, use sum() has to control the id for longitudinal data. how to control the id here?
*Do you want

bys id: g s=sum(x)
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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