江西财经大学营销调研stata软件笔记

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

.sysuse auto,clear 从内存中调一笔数据

.help sysuse 帮助菜单 help+其他单词都弹出帮助菜单

.sysuse dir 出来的结果↓

.auto.dta census.dta fscstage1.dta network1.dta strepto.dta

voter.dta autornd.dta cholesterol.dta gnp96.dta network1a.dta telomerase.dta xrcise4deprsn.dta bcg.dta citytemp.dta haloperidol.dta nlsw88.dta tsline1.dta xtline1.dta bplong.dta citytemp4.dta lifeexp.dta nlswide1.dta tsline2.dta

bpwide.dta educ99gdp.dta lubin97.dta pop2000.dta

uslifeexp.dta cancer.dta fleiss.dta magnes.dta sp500.dta uslifeexp2.dta

.sysuse sp500,clear 查询sp500的相关数据

.clear 清除数据

.edit 建立空白数据表格

.rename var1 code 把var1(原始表格列命名)重命名为code

.label variable val2 “年龄”

.label variable val2 “age”

.help rename 重命名的帮助菜单 webuse renamexmpl 从网上下载一些数据

des (describe the data)表格中的数据分析

renpfix income inc 批量更改数据

.insheet using "D:\data0507.txt",clear 通过命令导入文件

.sysuse auto,clear sumarize price.detail

.stata的命令结构如下

[bysort:] command [][][][][]

.help tab(tabulate)

sysuse census, clear

describe

contains data from D:\ado\base/c/census.dta

obs: (观测值) 50 1980 Census data by state

vars:(变量名) 13 6 Apr 2009 15:43

size: 3,100 (99.9% of memory free)

---------------------------------------------------------------------

---------------------------------------------------------------

storage display value

variable name type format label variable label

---------------------------------------------------------------------

---------------------------------------------------------------

state string字符→str14 %-14s State

state2 str2 %-2s Two-letter state abbreviation

region int %-8.0g cenreg Census region

pop long %12.0gc Population

poplt5 long %12.0gc Pop, < 5 year

pop5_17 long %12.0gc Pop, 5 to 17 years

pop18p long %12.0gc Pop, 18 and older

pop65p long %12.0gc Pop, 65 and older popurban long %12.0gc Urban population medage float %9.2f Median age

death long %12.0gc Number of deaths marriage long %12.0gc Number of marriages

--more--

.label(标签)

label define genderlb 1“男” 2“女”定义好标签 genderlb 1 选项为男,2选项为女

label values gender genderlb 将标签赋予gender

.drop xxx 删除某变量或观测

help drop

Examples

Setup

. sysuse census 提取census数据

Describe the data

. describe 查看详情

Drop all variables with names that begin with pop

. drop pop* 删除pop开头的变量

Describe the resulting data

. describe 查看详情

Drop marriage and divorce

. drop marriage divorce 删除变量marriage divorce

Describe the resulting data

. describe

Drop any observation for which medage is greater than 32

. drop if medage > 32 删除medage大于32的数据

Drop the first observation for each region

. by region, sort: drop if _n == 1 将region按sort排列再删除代号为1的数据

Drop all but the last observation in each region

. by region: drop if _n != _N 将region中每个代号保存一个

Keep the first 2 observations in the dataset

. keep in 1/2 留下二分之一

相关文档
最新文档