全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
3783 3
2015-11-19
data week;
         input name $ idno start;
         bonus=0;
         do year=start to 1991;/*from start to year add 50 every year*/
         if bonus ge 500 then leave;
         bonus+50;/*如果在do循环里是类似累加,循环进行到exit+1*/
        end;
        cards;
Jones        9011    1990  
Thomas    876      1976      
Barnes      7899    1991   
Harrell      1250     1975   
Richards  1002     1990   
Kelly         85        1981      
Stone      091       1990     

上面的案例运行出来的结果是:
                      Obs    name          idno      start      bonus     year
                        1     Jones          9011     1990      100      1992                        2     Thomas       876      1976      500      1986                        3     Barnes        7899     1991       50       1992                        4     Harrell         1250     1975       500     1985                        5     Richards     1002     1990       100      1992                        6     Kelly            85        1981       500      1991                        7     Stone          91        1990      100      1992为什么year变量里,第1个观测变成1992了,第2个观测变成1986了?求大侠指点~~


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2015-11-20 09:21:00
The LEAVE statement stops the processing of the current DO loop or SELECT group and continues DATA step processing with the next statement following the DO loop or SELECT group.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-11-20 09:38:16
孤单的我们 发表于 2015-11-20 09:21
The LEAVE statement stops the processing of the current DO loop or SELECT group and continues DATA s ...
嗯嗯,貌似有点点懂了,谢谢
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-11-20 10:19:11
这个LEAVE会终止你的循环,当你的1976+1一直到1986,10*50=500时,就跳出来了,并进行下一个观测的计算
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群