Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: Sql/sas

  1. #1
    Join Date
    Mar 2007
    Posts
    8

    Sql/sas

    Hello,

    I need to know how can I split the population evenly between two groups. Naming one group C and the other D

    For example:

    Number of population = 100

    Ouput:

    Group C=50
    Group D=50

    Please help

    Thanks,
    Nikki

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    On which rdbms? You mean split data in a table? Have more details?

  3. #3
    Join Date
    Mar 2007
    Posts
    8

    Sql/sas

    Well, I am pulling data from the table. I have the total population so I am trying to split the total population into two groups for one column in the table. I want to name these groups C and D

    For example:
    Column name Cells from table output
    total population = 100

    Output needs to be:
    Cells Population
    C 50
    D 50

    Hope this helps. I think, I can do this using When statement but not sure

    Thanks

  4. #4
    Join Date
    Sep 2002
    Posts
    5,938
    Do you want to split data based on value of other column or randomly?

  5. #5
    Join Date
    Mar 2007
    Posts
    8

    Sql/sas

    I have a program written in SAS and I want to distribute the total population into two groups evenly. Just randomly. So I will need to create a new dataset for this. But I am not sure how to do this.

  6. #6
    Join Date
    Sep 2002
    Posts
    5,938
    Which rdbms do you use?

  7. #7
    Join Date
    Mar 2007
    Posts
    8

    Sas/sql

    I use Oracle

  8. #8
    Join Date
    Sep 2002
    Posts
    5,938
    May split them based on rowid.

  9. #9
    Join Date
    Mar 2007
    Posts
    8

    Sas/sql

    Ok.. Like how.

    Could you help me with an example?

    Thanks!

  10. #10
    Join Date
    Sep 2002
    Posts
    5,938
    Possible to post your table schema?

  11. #11
    Join Date
    Mar 2007
    Posts
    8

    Sas/sql

    It's too big to post it here.

    It would be great if you can just show me an example on how to do it. If you could tell me which statement to use....should I use if/else or when....I am not sure and how should I divide them into two groups

  12. #12
    Join Date
    Sep 2002
    Posts
    5,938
    You want to split a table into two tables or what? If only need divide count in two groups to display, you can get it with count(*)/2.

  13. #13
    Join Date
    Mar 2007
    Posts
    8
    so how would I distribute the total number evenly into two groups? I am not splitting the table. I only want to split the number into two groups.

    For example:
    total = 100

    Output needs to be:
    Group Total
    C 50
    D 50

  14. #14
    Join Date
    Sep 2002
    Posts
    5,938
    Set total/2 for each group. Is group a column in the table? Total means number of rows in the table?

  15. #15
    Join Date
    Mar 2007
    Posts
    16
    The impression I get is that you have the following :

    select column1 as population from table1

    column1
    100
    200
    300

    this gives you all the population values, which i'm assuming you want to split in two, so...

    select (column1 / 2) as group c, (column1 / 2) as group d from table1

    group c | group d
    50 | 50
    100 | 100
    150 | 150

    If this is not what you want, then you need to be clearer in what you are saying.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •