Stata windows In stata command, it is helpful to point out stata is case sensitive, meaning that if a variable name include a capita letter, we must capitalize it.( Stata命令对大小写敏感) ● Open do file:在Do-fle中编程。直接的好处便是我们可以很方便的 执行以前写过的命令,并记录我们需要的命令,方便下一次的使用 和分析。在复杂的分析中,采用 Command窗口输入的方式会是非 常的困难,我们必须用do-fle去编程。另外,在do-fe文件中,用* 或者/and杉.表示注释内容, Stata在运行do-fe时会跳过这些注释 语句。加入注释语句能增强do-「le的可读性 Open the Do- File Editor. You can type"doedit"in the command window. When it first opens, the main screen is blank. You can type text into this main white screen to write our batch program Click on the Do button, B, to run the commands:'file name) Fudan University 6
Fudan University Stata windows ⚫ In stata command, it is helpful to point out stata is casesensitive, meaning that if a variable name include a capital letter, we must capitalize it. (Stata命令对大小写敏感) ⚫ Open do file:在Do-file中编程。直接的好处便是我们可以很方便的 执行以前写过的命令,并记录我们需要的命令,方便下一次的使用 和分析。在复杂的分析中,采用Command窗口输入的方式会是非 常的困难,我们必须用do-file去编程。另外,在do-file文件中,用* 或者/* and */.表示注释内容,Stata在运行do-file时会跳过这些注释 语句。加入注释语句能增强do-file的可读性。 – Open the Do-File Editor. You can type “doedit” in the command window. When it first opens, the main screen is blank. You can type text into this main white screen to write our batch program. – To RUN: select and “execute selection”; or do ***(file name) 6
4 Stata帮系统 Stata为用户提供强大的帮助系统。 Stata的帮助系统有三部分组成: 1. stata自带帮助系统是最方便和常用的。即hep<所要查询的命 令 2. Stata manua手册。按照字母顺序排列了 stata所有相关命令。 比较包括基本语法,还有具体操作实例,非常详细。 建议先阅读“ getting started with STATA”(gsW,pdn 3. Stata网络帮助系统: findit<所要查询的命令>,net; search< 所要查询的命令>,net 4.此外, stata网站自上有各种信息,还有 stata journa等 Fudan University
Fudan University 4 Stata帮助系统 ⚫ Stata为用户提供强大的帮助系统。Stata的帮助系统有三部分组成: 1. stata自带帮助系统是最方便和常用的。即help <所要查询的命 令>. 2. Stata manual 手册。按照字母顺序排列了stata所有相关命令。 比较包括基本语法,还有具体操作实例,非常详细。 • 建议先阅读“getting started with STATA”(gsw.pdf) 3. Stata网络帮助系统:findit <所要查询的命令> , net; search < 所要查询的命令>, net 4. 此外,stata网站自上有各种信息,还有stata journal等 7
5 stata语法和命令 [by varlist: ]command [varlist] [exp][if exp] [in range][weight]L, options ●最核心的是 command< varlist 例如 stata命令: tab policy sex,col 这条命令是告诉计算机按照sex(列变量)对 policy(行变量)做列联表, 并计算列百分比 常用的命令: Replace Codebook Summarize Describe Table Display(calculator) ablate Drop or keep Use(variable name)using Generate (file name) Label define Label variable Label value Recode Fudan University 8
Fudan University 5 stata语法和命令 ⚫ [by varlist:] command [varlist] [=exp] [if exp] [in range] [weight] [, options] ⚫ 最核心的是 command <varlist> – 例如stata 命令:tab policy sex, col – 这条命令是告诉计算机按照sex(列变量)对policy(行变量)做列联表, 并计算列百分比 ⚫ 常用的命令: – Codebook – Describe – Display (calculator) – Drop or keep – Generate – Label define – Label variable – Label value – Recode 8 - Replace - Summarize - Table - Tabulate - Use (variable name) using (file name)
6 stata主要功能模块 五大功能 1)数据处理, 2)绘图, 3)统计分析, 4)回归与建模分析, 5)编程。 Fudan University 9
Fudan University 6 stata 主要功能模块 ⚫ 五大功能: – 1)数据处理, – 2)绘图, – 3)统计分析, – 4)回归与建模分析, – 5)编程。 9
How data are stored in computer Data Editor Preserve Restore Sort Hide Delete. state[1] ta region popI t5 pop-5-to-1? POPI 8P aLabama South 3,893,888 296,412 865,836 2,731,648 aLAska West 4B1,851 38,949 91,796 271,166 Ar i zona West 2,718,215213,8857,6841,926,728 4 Arkansas South 2,286,48541759249,7821,1,61 5| California West23,67921,70,44,6,517,278,944 cOlorado West 2,889,964 216,495592,3182,681,151 7 Connecticut 3,187,576 185,188 637,731 284,657 8 Delaware South 41,151 125,44 427,743 9 Florida Sou th 9,746,324 57,2241,78,41217,3,86 10 Georgia South 5,463,105414,9351,231,1953,816,975 矩阵:行是样本,列是变量 Fudan University 10
Fudan University How data are stored in computer 10 矩阵:行是样本,列是变量