Mary Cairns Posted November 18, 2003 Posted November 18, 2003 Can anyone advise how to find a random 10% of my database for purposes of conducting a survey? I have 9800 records, each with an individual number. I need to select 10% at random.
Vaughan Posted November 18, 2003 Posted November 18, 2003 Create an unstored calculation field in your database (I'll call it cRdm but the name is arbitrary) cRdm = Random Make sure it's unstored, and the result type is set to number. Then create this script: Show all Records Sort [by field cRdm] Loop Exit Loop If [status(CurrentFoundCount) <= (Status(CurrentRecordCount) / 10)] Omit Record End Loop Every time you sort the database it'll sort differently (because the Random calculation will change each time because it's unstored). The loop then omits the unwanted records. I haven't tested this but it should work.
BobWeaver Posted November 18, 2003 Posted November 18, 2003 Rather than omit 90% of the records, why not omit 10% and then do a Show Omitted? Should be quicker. Show all Records Sort [by field cRdm] Loop Exit Loop If [status(CurrentFoundCount) <= (Status(CurrentRecordCount) *.9)] Omit Record End Loop Show Omitted
John Caballero Posted November 18, 2003 Posted November 18, 2003 Wow...both cool suggestions. I'd read this earlier and was wondering how best to go about this.
Ugo DI LUCA Posted November 19, 2003 Posted November 19, 2003 I guess without the loop, it will be even quicker. g_Percent (global number- Enter your percentage here) cRdm =Random SetField[g_Percent =Int(Status(CurrentRecordCount)*(g_Percent/100) )+1)] Show all Records Sort [by field cRdm] GoToRecord[by Field Value - g_Percent] OmitNext[500000-no dialog] * Put here one of these number of records you won't never have in your file...
Mary Cairns Posted November 19, 2003 Author Posted November 19, 2003 Thanks guys. It works beautifully. You are all angels.
Recommended Posts
This topic is 7675 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now