. sort market code
. by market:gen y=cratio[_n-1]
(3 missing values generated)
. replace y=0 if y==.
(3 real changes made)
. gen ratio=cratio-y
.
. gsort market -ratio
. by market: gen id=_n
. keep if id<5
(17 observations deleted)
. keep market id ratio
. table id market,c(mean ratio)
----------------------------------------
| market
id | 1 2 3
----------+-----------------------------
1 | .2051282 .1818182 .1403509
2 | .2051282 .1818182 .1403509
3 | .1538462 .1590909 .122807
4 | .1282051 .1363636 .1052632
----------------------------------------
.
end of do-file
[此贴子已经被作者于2009-2-19 18:56:14编辑过]