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了?求大侠指点~~