标签:
一、文件扩展名
数据文件 .dta
命令文件.do
程序文件.ado
二、不同统计软件的对比
三、使用wbopendata(世界银行公开数据)模块获取数据,减轻数据下载管理的工作量
例1:用wbopendata获得“每百人手机订购量“指标的元数据并制作地图
. wbopendata, language (en -English) indicator (it.cel.sets.p2) long clear latest
. use Mobile, clear
. spmap it cel sets p2 using "world-c.dta", id(id)
四、解决线性代数问题
例2:
1 //?线性变换可以用矩阵的形式表示,即x=Sy,y=Qz, 则x=S*Q*z.其中x,y,z??为列向量 2 mat S=(2,0,1\-2,3,2\4,1,5) 3 mat Q=(-3,1,0\2,0,1\0,-1,3) 4 mat b1=S*Q 5 mat l b1 //下面用方程形式表示出来 6 dis "x1="b1[1,1] "*z1+"b1[1,2] "*z2+"b1[1,3] "*z3" 7 dis "x2="b1[2,1] "*z1+"b1[2,2] "*z2+"b1[2,3] "*z3" 8 dis "x3="b1[3,1] "*z1+"b1[3,2] "*z2+"b1[3,3] "*z3" 9 //求解矩阵,先试探系数矩阵是否可逆 10 mat A=(2,1,-1\2,1,0\1,-1,1)p 11 dis det(A) //行列式不为零,可以求逆 12 mat b=(1,-1,3\4,3,2) 13 mat X=b*inv(A) 14 mat l X
五、自学途径
六、基本操作
.sysuse auto //使用sysuse打开系统示例数据 .sysuse auto,clear //使用clear命令来清除已打开的数据 .use abcd //使用use命令来打开用户自己的数据,默认打开C:\data或D:\data .cd”D:\abc“ //打开其他位置的数据文件,或者使用file--open来打开指定数据
describe:描述数据库变量类型、属性
. describe Contains data from F:\stata13(windows安装版)\ado\base/a/auto.dta obs: 74 1978 Automobile Data vars: 12 13 Apr 2013 17:45 size: 3,182 (_dta has notes) ------------------------------------------------------------------------------- storage display value variable name type format label variable label ------------------------------------------------------------------------------- make str18 %-18s Make and Model price int %8.0gc Price mpg int %8.0g Mileage (mpg) rep78 int %8.0g Repair Record 1978 headroom float %6.1f Headroom (in.) trunk int %8.0g Trunk space (cu. ft.) weight int %8.0gc Weight (lbs.) length int %8.0g Length (in.) turn int %8.0g Turn Circle (ft.) displacement int %8.0g Displacement (cu. in.) gear_ratio float %6.2f Gear Ratio foreign byte %8.0g origin Car type ------------------------------------------------------------------------------- Sorted by: foreign .
list:陈列相应的变量和数据
. list +----------------------------------------------------------------------+ 1. | make | price | mpg | rep78 | headroom | trunk | weight | | AMC Concord | 4,099 | 22 | 3 | 2.5 | 11 | 2,930 | |----------------------------------------------------------------------| | length | turn | displa~t | gear_r~o | foreign | | 186 | 40 | 121 | 3.58 | Domestic | +----------------------------------------------------------------------+ +----------------------------------------------------------------------+ 2. | make | price | mpg | rep78 | headroom | trunk | weight | | AMC Pacer | 4,749 | 17 | 3 | 3.0 | 11 | 3,350 | |----------------------------------------------------------------------| | length | turn | displa~t | gear_r~o | foreign | | 173 | 40 | 258 | 2.53 | Domestic | +----------------------------------------------------------------------+ +----------------------------------------------------------------------+ 3. | make | price | mpg | rep78 | headroom | trunk | weight | | AMC Spirit | 3,799 | 22 | . | 3.0 | 12 | 2,640 | |----------------------------------------------------------------------| | length | turn | displa~t | gear_r~o | foreign | | 168 | 35 | 121 | 3.08 | Domestic | +-----------------------------------------------------------------------
//在list之后加上限制条件选取所需数据 //列出价格大于10000的车型 . list make if price > 10000 +-------------------+ | make | |-------------------| 9. | Buick Riviera | 11. | Cad. Deville | 12. | Cad. Eldorado | 13. | Cad. Seville | 26. | Linc. Continental | |-------------------| 27. | Linc. Mark V | 28. | Linc. Versailles | 41. | Olds Toronado | 64. | Peugeot 604 | 74. | Volvo 260 | +-------------------+ . //列出价格大于10000的进口车车型 . list make if price>10000 & foreign == 1 +-------------+ | make | |-------------| 64. | Peugeot 604 | 74. | Volvo 260 | +-------------+ .
直接使用browse命令打开数据库浏览
.browse
scatter:绘制散点图
. scatter price weight
generate:生成一列新数据
.g num = _n //generate或gen都可以
用list num可查看新生成的变量
. list num +-----+ | num | |-----| 1. | 1 | 2. | 2 | 3. | 3 | 4. | 4 | 5. | 5 | |-----| 6. | 6 | 7. | 7 | 8. | 8 | 9. | 9 | 10. | 10 | |-----| 11. | 11 | 12. | 12 | 13. | 13 | 14. | 14 | 15. | 15 | |-----| 16. | 16 | 17. | 17 | 18. | 18 |
.replace //+条件语句:剔除缺失值、异常值、批量修改数据 .edit //慎用,避免无意间修改了原始数据
注意:原始数据不允许随便修改
summarize:求变量的个数、平均值、标准差、最小值和最大值
. su //summarize或sum都可以 Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- make | 0 price | 74 6165.257 2949.496 3291 15906 mpg | 74 21.2973 5.785503 12 41 rep78 | 69 3.405797 .9899323 1 5 headroom | 74 2.993243 .8459948 1.5 5 -------------+-------------------------------------------------------- trunk | 74 13.75676 4.277404 5 23 weight | 74 3019.459 777.1936 1760 4840 length | 74 187.9324 22.26634 142 233 turn | 74 39.64865 4.399354 31 51 displacement | 74 197.2973 91.83722 79 425 -------------+-------------------------------------------------------- gear_ratio | 74 3.014865 .4562871 2.19 3.89 foreign | 74 .2972973 .4601885 0 1
标签:
原文地址:http://www.cnblogs.com/pursuit1996/p/4606163.html