stata入门中文讲义(4)

2019-08-31 12:13

sum price retu list

g cv=r(sd)/r(mean) di cv

. sysuse auto,clear(1978 Automobile Data). sum price Variable Obs Mean Std. Dev. Min Max price 74 6165.257 2949.496 3291 15906. retu listscalars: r(N) = 74 r(sum_w) = 74 r(mean) = 6165.256756756757 r(Var) = 8699525.974268789 r(sd) = 2949.495884768919 r(min) = 3291 r(max) = 15906 r(sum) = 456229. g cv=r(sd)/r(mean). di cv.47840601

2.

sysuse auto,clear reg mpg price weight g r2 = e(mss)/(e(mss)+e(rss)) di r2

16

. sysuse auto,clear(1978 Automobile Data). . reg mpg price weight, noheader mpg Coef. Std. Err. t P>|t| [95% Conf. Interval] price -.0000935 .0001627 -0.57 0.567 -.000418 .0002309 weight -.0058175 .0006175 -9.42 0.000 -.0070489 -.0045862 _cons 39.43966 1.621563 24.32 0.000 36.20635 42.67296 . . g r2 = e(mss)/(e(mss)+e(rss)). . di r2.65314466

3.

sysuse auto, clear

global varlist mpg price weight sum $varlist

local varlist mpg price weight sum `varlist’

. global varlist mpg price weight. . sum $varlist Variable Obs Mean Std. Dev. Min Max mpg 74 21.2973 5.785503 12 41 price 74 6165.257 2949.496 3291 15906 weight 74 3019.459 777.1936 1760 4840. . local varlist mpg price weight. . sum `varlist' Variable Obs Mean Std. Dev. Min Max mpg 74 21.2973 5.785503 12 41 price 74 6165.257 2949.496 3291 15906 weight 74 3019.459 777.1936 1760 4840

17

4.

cap drop sum qui generate sum=0

foreach var of varlist headroom length { } sum sum

. cap drop sum. . qui generate sum=0. . foreach var of varlist headroom length { 2. . qui replace sum = sum + `var' 3. . }. . sum sum Variable Obs Mean Std. Dev. Min Max sum 74 190.9257 22.71468 145 236.5qui replace sum = sum + `var’

第二章 数据管理和画图

2.1数据类型和格式

内部数值型数据有五种模式 存在类型 byte int long float

字节数 1 2 4 4 8

最小 -127

最大 100 32,740 2,147,483,620 1.70141173319х1038 8.9984656743х10307

-32,767

-2,147,483,647

-1.70141173319х1038 -8.9984656743х10307

double

另外,还有字符型数据,与其相关的两条命令是destring,将字符型变量转变为数值型,tostring则将数值型转化为字符型。encode/decode

18

数据显示格式可以利用命令format来进行调整,具体参数有 f g e c

固定形式 一般形式 指数形式 千分位加豆号

.2f 3.5555 3.56

可以利用命令help format了解数据显示格式的更多内容。

2.2 数据输入

use import excel insheet odbc

infile (free format) infix (fixed format) import sasxport haver xmluse

Stata格式数据的输入 use filename [, clear nolabel]

use [varlist] [if] [in] using filename [, clear nolabel] 例:use auto, clear

use if foreign==1 using auto, clear 输入文本文件数据

insheet [varlist] using filename [, options] [no]double override default storage type tab tab-delimited data

19

comma comma-delimited data delimiter(\ clear replace data in memory case preserve variable name's case

[no]names variable names are included on the first line of the file 例:

insheet using [path] gdp.txt, clear ….

ODBC 调入ACCESS文件(工业企业数据)

c:\\Windows\\SysWoW64\\odbcad32

odbc load, table(“QY05”)

20


stata入门中文讲义(4).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:废旧轮胎回收利用创业方案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: