我有以下initial.dta
數據集:Stata。如何發佈按類型的矩陣?或者如何返回矩陣的值?
obs. ID city salary
1 123 Normal 100
2 124 Paris 120
3 125 NY 130
4 122 .a 155
5 120 Paris 100
6 128 Chicago 150
................
的city
和salary
一些值可能會丟失(.a)中。我需要計算平均工資爲每一個可能的城市價值,並將其發佈到不同的Stata .dta,從而使新的Stata文件應該是這樣的:
city averageSalary
Normal 120
Paris 110
NY 150
.a 108
Chicago 160
.................
我嘗試這樣做:
clear
postfile myPost city averageIncome using target.dta
use initial, clear
sort city
by city: sum salary, meanonly
post myPost (`r(city)') (`r(mean)') // This line does not execute.
postclose myPost
這裏有什麼問題?請有人回答這個問題。或發表評論......
非常感謝。按照您的建議,我將您的示例與Maarten Buis結合使用。 – CHEBURASHKA