Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Random Record Selection Problems.
Message
De
15/12/2003 15:22:26
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Random Record Selection Problems.
Divers
Thread ID:
00859259
Message ID:
00859259
Vues:
60
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
Fil
Voir

Click here to load this message in the networking platform