Results 1 to 4 of 4
  1. #1
    ldashev is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2016
    Posts
    3

    Sampling based on the ratio of the whole population

    I have a population of records...let's say 10,000 athletes, grouped by sports, where (numbers below would be variable):


    4,000 are from NBA
    2,000 are from NHL
    3,000 are from MLB
    1,000 are from NFLHow can I build a sample query that will sample 100 records based on the population(meaning calculate how much NBA/NHL/MLB and NFL components are with respect to the total population and then apply that to the sample) not fully random but pull out:

    NBA/Whole Population=X
    Select Top X * From MainTable Where league= 'NBA' (something like this)


    40 names are from NBA
    20 names are from NHL
    30 names are from MLB
    10 names are from NFL

    This is just a sample of the population, logic here is to calculate what the ratios are with regard to the whole population and then apply them to the sample size.
    Regards

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    I fear this may be vba only solution

    Design a query to find how many of each (and total) then use vba to:

    Calculate quantity of each one (ensuring they add up to total)

    SQL = "select top " & n
    Firstname, lastname
    From tblpopulation
    Where sports = "NBA" etc

    Happy to help more should you need it but not sure of your expertise in vba





    Sent from my iPad using Tapatalk

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    And what do you want to do with these records? Display in a query, write them to a table, ...???


    If you use
    Code:
    "SELECT top 40....
    you will get the same records (athletes). To pull random athletes, see these two sites (there are a lot more sites):
    http://www.techrepublic.com/blog/how...rosoft-access/
    http://stackoverflow.com/questions/9...from-ms-access

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to calculate conversion ratio
    By aparnawangu in forum Queries
    Replies: 3
    Last Post: 01-05-2016, 12:43 PM
  2. Statistical Sampling
    By RayMilhon in forum Access
    Replies: 4
    Last Post: 07-12-2012, 02:01 PM
  3. ratio 1:10- catering service
    By natalia in forum Queries
    Replies: 2
    Last Post: 10-13-2010, 06:44 PM
  4. Ratio calculation - Need help
    By Kai in forum Queries
    Replies: 5
    Last Post: 06-14-2010, 08:25 PM
  5. Random sampling
    By uscpa in forum Queries
    Replies: 4
    Last Post: 01-23-2010, 03:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums