|
Hi,
It is extremely likely that your source
dataset contains a variable called "i".
And as soon as you run your original code
the row_to_read may be 915, and thus when
the SET statement reads the observation
from row 915 the value of i gets overwritten
and then your DO loop loops around and the
test for 100 fails and you only get one
observation. If you change your DO loop
from "i" to "j" I bet it will work as this
sample code below does. e.g.
data file;
do i = 1 to 2000;
output;
end;
run;
data work.sample1;
do j = 1 to 100;
row_to_read = int(uniform(int(time()))*2000+1);
put _all_;
set work.file point = row_to_read;
output;
end;
stop;
run;
Hope this is helpful.
Mark Terjeson
Senior Programmer Analyst, IM&R
Russell Investment Group
Russell
Global Leaders in Multi-Manager Investing
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Xuhong
Sent: Wednesday, November 08, 2006 12:25 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: what's wrong with my codes? please help!
Dear all,
I have a database with 2000 obeservations and what I need is to random
select 100 observations with replacement. But my codes could only
generate one observation. Could you help me find out my mistakes in my
codes below? Thanks very much!
data work.sample1;
do i = 1 to 100;
row_to_read = int(uniform(int(time()))*2000+1);
set work.file
point = row_to_read;
output;
end;
stop;
run;
|