你很近。你需要聲明一個數組。你不解釋前半部分是什麼(e ** i部分),所以目前還不清楚你想要的是什麼 - 你想要幾千行e的權力,然後一些行x1-x30?你爲什麼每次輸出第二個循環?要回答的核心問題,在這裏:
DATA maarah (drop = i e);
e = constant("e");
do i = -10 to 10 by 0.01;
x=i;
y=e**x;
output;
end;
*length x1-x30 $2001; *what is this? Why do you want it 2001 characters, instead of numeric?;
array xs x1-x30; *you would need a $ after this if you truly wanted character;
do i =1 to 30 by 1;
xs[i]=x**i;
*output; *You probably do not want this. Output is probably outside of the loop.;
end;
run;
我猜你真正想要的是這樣的:
DATA maarah (drop = i e);
e = constant("e");
do i = -10 to 10 by 0.01;
x=i;
y=e**x;
*length x1-x30 $2001; *what is this? Why do you want it 2001 characters, instead of numeric?;
array xs x1-x30; *you would need a $ after this if you truly wanted character;
do j =1 to 30;
xs[j]=x**j;
end; *the x1-x30 loop;
output;
end; *the outer loop;
run;
來源
2014-02-28 14:37:10
Joe
此代碼給1個觀察我需要2000 – dmitriy
它給我的只是其中的第一步循環(i = -10)。 – dmitriy
有一個錯字,並意識到你應該將第二個循環的循環計數器切換到別的東西 - 修正 – Joe