1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
webuse lifeexp,clear tostring region, g(region2) tostring region, replace tostring *, replace tostring *, replace force
webuse destring2, clear destring date, i(" ") gen(newdate) destring percent, i("%") replace destring price, i("$" ",") g(price2) destring price, i("$") replace force
webuse lifeexp, clear
list
gsort + safewater list safewater in 1/20 gsort - safewater list safewater in 1/20
list country safewater if region==1
summ lexp safewater summ lexp safewater, d
summ lexp safewater if region==1
tab safewater tab safewater, m
tab region tab region, nol
tab lexp if region==1
tabstat lexp, stat(n mean max min sd range) f(%9.3f) by(region)
tabstat lexp, stat(p1 p5 p10 q p90 p95 p99) f(%9.3f) by(region)
cd "C:/Users/wugan/Desktop/教对象Stata系列/第3课:变量管理、统计分析与数据管理/示范数据"
webuse lifeexp, clear keep if region==1 save "亚欧", replace webuse lifeexp, clear keep if region!=1 save "美洲",replace
use "亚欧", clear append using "美洲" save "亚欧+美洲", replace
use "气象数据", clear merge 1:1 CID using "产业增加值" rename CID 城市代码 merge 1:1 城市代码 using "产业增加值" rename year 年份 merge 1:1 年份 城市代码 using "产业增加值"
merge 1:1 年份 城市代码 using "产业增加值", force
destring 年份 城市代码, replace merge 1:1 年份 城市代码 using "产业增加值" keep if _merge==3 save "气象+增加值", replace
cd "C:/Users/wugan/Desktop/教对象Stata系列/第3课:变量管理、统计分析与数据管理/综合案例数据"
use "CFPS2018/2018家庭经济", clear keep fid18 cyear fwage_1 foperate_1 fproperty_1 ftransfer_1 felse_1 fincome1 daily-expense save "DATA/2018家庭经济",replace
use "CFPS2018/2018家庭成员关系", clear egen famsize=count(fid18), by(fid18) label var famsize "家庭规模" egen famage=mean(2018-tb1y_a_p), by(fid18) label var famage "家庭平均年龄" keep fid18 cyear famsize famage
duplicates drop fid18, force save "DATA/2018家庭成员关系",replace
use "DATA/2018家庭经济", clear merge 1:1 fid18 using "DATA/2018家庭成员关系" keep if _merge==3 save "DATA/CFPS2018", replace
use "CFPS2016/2016家庭经济", clear keep fid16 cyear fwage_1 foperate_1 fproperty_1 ftransfer_1 felse_1 fincome1 daily-expense save "DATA/2016家庭经济",replace
use "CFPS2016/2016家庭成员关系", clear egen famsize=count(fid16), by(fid16) label var famsize "家庭规模" egen famage=mean(2016-tb1y_a_p), by(fid16) label var famage "家庭平均年龄" keep fid16 cyear famsize famage
duplicates drop fid16, force save "DATA/2016家庭成员关系",replace
use "DATA/2016家庭经济", clear merge 1:1 fid16 using "DATA/2016家庭成员关系" keep if _merge==3 save "DATA/CFPS2016", replace
use "DATA/CFPS2018", clear append using "DATA/CFPS2016" rename fid18 fid replace fid=fid16 if fid==. & fid16!=. drop fid16 _merge save "DATA/CFPS(16-18)", replace
|