Information générale
Catégorie:
Codage, syntaxe et commandes
Titre:
Random Record Selection Problems.
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
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement