1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
set obs 50
gen a = _n
gen year = 1991 if inrange(a,1,10)
replace year = 1993 if inrange(a,11,20)
replace year = 1995 if inrange(a,21,30)
replace year = 1997 if inrange(a,31,40)
replace year = 2000 if inrange(a,41,50)
gen c = uniform()
bys year:gen id = _n
drop a
xtset id year
*生成属性(来自下一轮)
by id: gen next = c[_n+1]
*生成属性(来自上一轮)
by id: gen back = c[_n-1]
*生成属性(来自第一轮)
by id: gen first = c[1]
|