Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Generating combinations ids of a certain size

    hello, i'm new to the forums and rather new to stata,

    I have data that is arranged by country and by year. There are 30 countries in the data set. What I would like to be able to do is to generate all combinations of size 27 out of the 30 countries and sum values together in the combination. This should be 30 choose 27 so ~4000.

    For example, my data looks kind of like this

    Country Year GDP
    AUS 1999 4000
    AUS 2000 50000
    AUS 2001 6000
    USA etc etc.
    USA
    USA
    GBR
    GBR
    GBR
    MEX
    MEX
    MEX
    ....

    I would like to be able to select 27 countries and then add GDP in each year and I would like to do this for all possible combinations. I looked into egen to do this, but wasn't exactly sure. Any help is much appreciated!!


  • #2
    Code:
     
    ssc desc tuples

    Comment


    • #3
      i see how this generates the combinations i need, how might i add GDP and create new sets of observations based on these combinations?

      Comment


      • #4
        Sorry, but I don't understand the rest of your problem, which is rather broadly sketched.

        But it is usually neither necessary nor helpful to create multiple overlapping copies of the dataset with a subset in each. In your case it is probably much easier to think about which 3 of 30 countries you are excluding! So, you might cycle around those possibilites with a condition

        Code:
        if !inlist(country, <tuple excluded>)
        But are you reinventing jackknife used with a cluster?
        Last edited by Nick Cox; 22 Mar 2015, 03:54.

        Comment

        Working...
        X