1) Describe 数据的简要描述 d2) List 将所有数据列在 result 里面 l3) Summarize 分析统计指标 su4) correlate 统计各个变量之间的相关系数 cor5) graph twoway connected math score,yaxis(1)||connected english score,yaxis(2) title(“”)横坐标表示 score 左 y 轴表示数学 右 y 轴表示英语6) browse chinese math if score>640 只显示总分大于 640 的数学和语文的成绩7) edit math ability score 只显示数学 基本能力和总分,可以进行编辑8) gen any=uniform() 新建一个随机变量 ,从 0-19) list math chinese english in 60/70 列出其中 60-70 个观测值的数学语文和英语10) replace any=100*any 将 ANY 这个变量的值*100,然后取代原来的变量11) sample 10 仅剩下随即的 10%,sample 30,count 随机的剩下 30 个观测值12) gsort –math 按数学从高到低排序13) gsort name 将观测值的姓名顺序排序14) gsort –name 姓名逆序排序15) help gesort 排序的帮助16) tabulate math if score>600 在 result 窗口中显示 总分 600 以上的数学得 频数 百分比及累计百分比17) edit math score 在编辑器窗口中只显示数学和总分18) list in 4 在 result 窗口中只显示第 4 个观测值19) list in 10/20 列出第 10-20 个观测值20) sum if score>660 只对总分大于 660 的观测值进行统计分析21) sun if place !=”canada”对字符串的除外统计22) sum if score>600&score620|(math>=140&english>=135)列出其中的总分大于 620 或者数学大于140 和英语大于 135 的观测值24) help datafun 寻找日期的命令25) help strfun 字符串函数26) dispay 作为统计显示的计算器使用27) sum math ,display r(mean),gen mathdev=math-r(menn),sum math mathdev28) help egen 生成函数的扩展29) tabulate class,gen (class) 在编辑窗口 新生成 16 个变量,class26-41 ,并且以 0-1 表示30) list class class10-class14 在 result 中只显示 10-14 班的内容31) sum math if class!=28 对数学进行求统计量,然后排出 28 班32) replace score2=1 if score >=600&score<.主要针对缺失值的运算 因为缺失值.被认为是非常大的数。
33) gen score3=autocode(score,4,600,700) 将编辑器中的数据,按照 625 650 675 700 进行分类34) list score score2 score3 此时 result 窗口显示的是每一个分数对应的指标,是否是600 以上的,在哪个区间上?35) gen score5=group(5) 将编辑器中的数据按规模分为 5 组36) gen caseid=_n 在编辑器里面创建一个变量 从 1-2-3.37) display score[45] 此时是在上一步的基础上选择第 45 条观测值38) gen difscore=score-score[_n-1]生成一个新变量 difscore 其数值=序列 2 的数据减去序列 1 的数据,依次排列39) use laizhou20;uselaizhou40;append using laizhou20 注意最后那个合并命令中的using 指的是当前编辑器中的文件数据,所以后面应该是加上最开始打开的那个数据laizhou2040) xpose,clear varname 在 result 中转置的命令pro v1 v2 v3 v4 v5a 22 23 34 55 66b 23 55 53 34 45c 33 45 43 43 66d 334 444 43 43 555里面是三个变量组成 的图标,现在要将其变成长格式。
Reshape long v,i(pro) j(n)+---------------+| pro n v ||---------------|1. | a 1 22 |2. | a 2 23 |3. | a 3 34 |4. | a 4 55 |5. | a 5 66 ||---------------|6. | b 1 23 |7. | b 2 55 |8. | b 3 53 |9. | b 4 34 |10. | b 5 45 ||---------------|11. | c 1 33 |12. | c 2 45 |13. | c 3 43 |14. | c 4 43 |15. | c 5 66 ||---------------|16. | d 1 334 |17. | d 2 444 |18. | d 3 43 |19. | d 4 43 |20. | d 5 555 |+---------------+41) reshape long grow,i(pro)j(year)42) graph twoway connected v n,yline(0) by(pro)020406002040601 2 3 4 51 2 3 4 5a bc dvnGraphs by pro43) collapse (mean) grow,by(pro)44) set obs 1000 模拟 1000 次随机的掷骰子的程序obs was 0, now 1000. gen roll=1+trunc(6*uniform()). tab rollroll | Freq. Percent Cum.------------+-----------------------------------1 | 168 16.80 16.802 | 179 17.90 34.703 | 139 13.90 48.604 | 175 17.50 66.105 | 171 17.10 83.206 | 168 16.80 100.00------------+-----------------------------------Total | 1,000 100.0045) histogram english,frequency xlabel(0(2)150) ylabel(0(2)100) ytick(1(2)101) start(0) width(2)46) histogram english,frequency xlabel(0(5)150) ylabel(0(2)33) ytick(1(5)21) start(0) width(1)47) histogram english,frequency title("chenkui") xlabel(0(5)150) ylabel(0(2)33) ytick(1(5)21) start(0) width(1)48) graph twoway line cl ca t02000400060000 5 10 15 20 25tcl ca49) graph twoway line cl t,connect(stairstep) 10002000300040005000cl0 5 10 15 20 25t50) graph twoway line cl t 10002000300040005000cl0 5 10 15 20 25t51) graph twoway connected cl t 10002000300040005000cl0 5 10 15 20 25t52) graph hbar math english ,over(class)53) 0 50 10 1504140393837363534332313029282726mean of math mean of english54) graph bar (sum) math english chinese,over(class) 02,004,006,008,002627282930313233435363738394041sum of math sum of englishsum of chinese55) histogram score ,start(0) width(25) xlabel(0(50)700) frequency norm 05010150Frequency0501015020250303504045050506065070score56) qnorm score,grid 分位- 正态图315366420406080score51.704 676.962346.4620 40 60 80Inverse NormalGrid lines are 5, 10, 25, 50, 75, 90, and 95 percentiles57) graph combine 111.gph 222.gph 0.00.250.500.751.0Normal F[(score-m)/s]0.0 0.25 0.50 0.75 1.0Empirical P[i] = i/(N+1)20406080score20 40 60 80Inverse Normal58) tabstat score 求平均数59) tabstat score,stats(min p5 p50 p75 max) by(class) 分班级计算总分的各个指标60) ci score,level(95)计算总分的均值的置信区间61) ladder 初步判断哪个更合适 gladder 直方图表示 qladder 分位正态图表示62)1 2 3 4 5 6。