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;
|
|
o****o 发帖数: 8077 | 2 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 | 3 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"? |
|
w********5 发帖数: 72 | 4 Is it because you reset these to 1 every time? Waiting for better anwer.
ndat = 1;
id = 1;
time = 1; |
|
b**********i 发帖数: 1059 | 5 写了个sas simulation,主要用nlmixed procedure。simulated datset 有160万个
record(1000次simulation合一起),10几个variable。昨天test了100次simulation
(也就是16万个record),只花了半个多小时。昨天走前设成1000次sim一早来程序还
在慢慢爬。问问先进是不是因为sas到了瓶颈了。 我的机器Q6600 2G RAM, winxp.
想着改写成个loop 让sas一次simulate一个 dataset 1600 个record,应该会快。不过
还不不清楚sas里怎么实现。 用别的语言的话在一个loop里面run就可以了。
R的话类似
result<-matrix(...).
for (ndat in 1:1000){
...
result[ndat,]<-...} 就可以了
用sas的话 datastep 或者procedure怎么在loop里面实现?是用macro吗,哪位大虾给
个意见?
谢谢 |
|
b*******r 发帖数: 152 | 6 'coz you put the 'output' stmt within the most inner loop. it only gets
executed in THAT loop. |
|
b*******r 发帖数: 152 | 7 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 | 8 yeah, you need an output statement for every do while loop, and it's more
complicated than that.
the second approach is better. |
|
b**********i 发帖数: 1059 | 9 真的看明白了。time = 1 redundent了。现在都不太动脑脑子弱弱的跟文科MM差不多。 |
|
o****o 发帖数: 8077 | 10 看来你是理科mm
你跟白菜truecabbage啥关系?兄妹? |
|
b**********i 发帖数: 1059 | 11 据说地球上两个人要扯上关系只要经过6个中间人?我跟白菜可能也要经过这么多中介
。白菜到底是谁啊,似乎很有名哦。 |
|
|