作者porfu (一个人)
站内Statistics
标题Re: [程式] Stata 重复变数的值
时间Tue Jun 9 06:00:43 2015
※ 引述《SonicJuice (光阴四溅)》之铭言:
: 就是将一个原本的变数里的值,连着重复出现我要的次数。
: [程式范例]:
这用R会容易很多,不过Stata可以用reshape。以下是例子:
clear
input quart qval
1 120
2 240
3 180
4 210
end
forval i=1/3 {
gen mval`i'=qval/3
}
reshape long mval,i(quart)
gen month=_n
drop _j qval
order quart month mval
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 128.101.83.82
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Statistics/M.1433800845.A.C4D.html