最新精选stata入门7流程语句.doc

  1. 1、本文档共19页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
7 流程语句 7.1循环语句:while 任务7.1:用循环语句编写程序,依次列出1,2,3,4,5 程序示例: *============================begin================================= capture drop count5 program count5 local i=1 //先将宏名为i的宏值设为1 while `i’=5 { //判断如果宏值`i’不大于5,就执行{}中的命令,否则跳开 display `i’ //要干的活是显示宏值`i’ local i=`i’+1 //重新设定宏名为i的宏值,令其等于`i’+1 } end *============================end================================== count5 1 2 3 4 5 看看这些结果,`i’最初设为1,因为1小于5,因此显示1;显示完毕紧随其后的命令,将i重新设定(即加上1),重新设定后`i’现在等于2,由于2仍然小于5,于是显示2,并再次重新设定i,…,直到`i’与6等价,不再小于等于5,跳出循环{},执行end. 补充知识:数列的表示方法 2 just one number 1 2 3 three numbers 3 2 1 three numbers in reversed order .5 1 1.5 three different numbers 1 3 -2.17 5.12 four numbers in jumbled order 1/3 three numbers: 1, 2, 3 3/1 the same three numbers in reverse order 5/8 four numbers: 5, 6, 7, 8 -8/-5 four numbers: -8, -7, -6, -5 -5/-8 four numbers: -5, -6, -7, -8 -1/2 four numbers: -1, 0, 1, 2 1 2 to 4 four numbers: 1, 2, 3, 4 4 3 to 1 four numbers: 4, 3, 2, 1 10 15 to 30 five numbers: 10, 15, 20, 25, 30 1 2:4 same as 1 2 to 4 4 3:1 same as 4 3 to 1 10 15:30 same as 10 15 to 30 1(1)3 three numbers: 1, 2, 3 1(2)9 five numbers: 1, 3, 5, 7, 9 1(2)10 the same five numbers: 1, 3, 5, 7, 9 9(-2)1 five numbers: 9, 7, 5, 3, and 1 -1(.5)2.5 the numbers: -1, -.5, 0, .5, 1, 1.5, 2, 2.5 1[1]3 same as 1(1)3 1[2]9 same as 1(2)9 1[2]10 same as 1(2)10 9[-2]1 same as 9(-2)1 -1[.5]2.5 same as -1(.5)2.5 1 2 3/5 8(2)12 eight numbers: 1, 2, 3, 4, 5, 8, 10, 12 1,2,3/5,8(2)12 the same eight numbers 1 2 3/5 8 10 to 12 the same eight numbers 1,2,3/5,8,10 to 12 the same eight numbers 1 2 3/5 8 10:12 the same eight numbers 7.3循环语句:forvalues 程序示例: *============================begin================================= forvalues i=1/5 { display `i’ //和上一个命令完全等价,只是写法更简洁 } *============================end================================== 程序示例3: *============================begin================================= forvalues i=4 (-0.2) 0{ //起始值可大于终值,但步长应为负,步长可为小

文档评论(0)

xingyuxiaxiang + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档