Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Random Record Selection Problems.
Message
From
15/12/2003 15:22:26
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Random Record Selection Problems.
Miscellaneous
Thread ID:
00859259
Message ID:
00859259
Views:
61
I need to create a randomly selected 20% sample on a table. Here is the code that I use:

SELECT finallist
ALTER table finallist ADD COLUMN RandSel n(1,0)

FOR i = 1 TO INT(reccount()*.2)
LOCATE for RECNO() = INT(RAND()*RECCOUNT())
IF finallist.RandSel <> 1 then
replace RandSel WITH 1
ELSE
SKIP 1
replace RandSel WITH 1
ENDIF
ENDFOR

SELECT * from finallist WHERE RandSel = 1 INTO TABLE RandomList

The problem that I am encountering is the function INT(RAND()*RECCOUNT()) changed value every time a new line of code gets executed. This seems to work with STEP ON. In the debug window I can watch the value of that expression change every time a line of code is ececuted. Is there a way to stop that or to do it different?

Any suggestions would be appreciated.

Thanks
Next
Reply
Map
View

Click here to load this message in the networking platform