b**********i 发帖数: 1059 | 1 /* ids and time points */
data temp_id;
ndat = 1;
id = 1;
time = 1;
do while (ndat LE &ndats);
do while (id LE &nobs);
do while (time LE &niobs);
output temp_id;
time + 1;
end;
id + 1;
end;
ndat + 1;
end;
run;
proc print data = temp_id;
run;
用下面这个就没有问题
/* ids and time points */
data temp_id;
do ndat = 1 to &ndats;
do id= 1 to &nobs;
do time = 1 to &niobs;
|
w********5 发帖数: 72 | 2 Is it because you reset these to 1 every time? Waiting for better anwer.
ndat = 1;
id = 1;
time = 1; |
b*******r 发帖数: 152 | 3 'coz you put the 'output' stmt within the most inner loop. it only gets
executed in THAT loop. |
b*******r 发帖数: 152 | 4 here is the tricky part of the different looping -- execution flow is
different.
try another approach. instead of using do while ( <= ), use do until ( > ).
you will get what u need. |
b******e 发帖数: 539 | 5 yeah, you need an output statement for every do while loop, and it's more
complicated than that.
the second approach is better.
【在 b*******r 的大作中提到】 : 'coz you put the 'output' stmt within the most inner loop. it only gets : executed in THAT loop.
|
o****o 发帖数: 8077 | 6 should be like this, note the arrows:
/* ids and time points */
data temp_id;
ndat = 1;
id = 1;
time = 1;
do while (ndat LE &ndats);
do while (id LE &nobs);
do while (time LE &niobs);
output temp_id;
time + 1;
end;
id + 1; time=1; /*<--------*/
end;
ndat + 1; id=1; /*<---------*/
end;
run; |
b**********i 发帖数: 1059 | 7 This program works perfectly. I can see why we need to reset time = 1 in "id
+1; time +1;", but similarly why it's not "ndat + 1, id +1, time + 1",
instead of "ndat+1, id+1"?
【在 o****o 的大作中提到】 : should be like this, note the arrows: : /* ids and time points */ : data temp_id; : ndat = 1; : id = 1; : time = 1; : do while (ndat LE &ndats); : do while (id LE &nobs); : do while (time LE &niobs); : output temp_id;
|
b**********i 发帖数: 1059 | 8 真的看明白了。time = 1 redundent了。现在都不太动脑脑子弱弱的跟文科MM差不多。 |
o****o 发帖数: 8077 | 9 看来你是理科mm
你跟白菜truecabbage啥关系?兄妹?
【在 b**********i 的大作中提到】 : 真的看明白了。time = 1 redundent了。现在都不太动脑脑子弱弱的跟文科MM差不多。
|
b**********i 发帖数: 1059 | 10 据说地球上两个人要扯上关系只要经过6个中间人?我跟白菜可能也要经过这么多中介
。白菜到底是谁啊,似乎很有名哦。
【在 o****o 的大作中提到】 : 看来你是理科mm : 你跟白菜truecabbage啥关系?兄妹?
|
o****o 发帖数: 8077 | 11 可以先研究一下脸书中所有人的关系
【在 b**********i 的大作中提到】 : 据说地球上两个人要扯上关系只要经过6个中间人?我跟白菜可能也要经过这么多中介 : 。白菜到底是谁啊,似乎很有名哦。
|