Announcement

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

  • Average values of dependent variable

    Hi everyone,

    I have one question which is a little bit harder to explain but I will give my best.

    I have one index which I want that is my dependent variable but it is only published every second year (2008 2010 etc.) But I really wanna use that index in my paper and my idea was to take average for to years. So for example if the value of index for 2008 is 82 than I thought to divided by two and put that the values for 2008 is 41 and for 2009 is 41.
    Can I do that for every years in my panel data?

    Thank you in advance.

  • #2
    Your explanation didn't extend to a data example, or telling us about variable names (FAQ Advice #12). Nevertheless this shows some technique which may be helpful:

    Code:
    clear
    set obs 12 
    gen id = cond(_n <= 6, 1, 2) 
    bysort id: gen year = 2007 + _n 
    gen whatever = 2 * _n if mod(year, 2) == 0 
    bysort id  (year) : gen wanted = cond(mod(year, 2) == 0, whatever/2, whatever[_n-1]/2) 
    list, sepby(id) 
    
         +-------------------------------+
         | id   year   whatever   wanted |
         |-------------------------------|
      1. |  1   2008          2        1 |
      2. |  1   2009          .        1 |
      3. |  1   2010          6        3 |
      4. |  1   2011          .        3 |
      5. |  1   2012         10        5 |
      6. |  1   2013          .        5 |
         |-------------------------------|
      7. |  2   2008         14        7 |
      8. |  2   2009          .        7 |
      9. |  2   2010         18        9 |
     10. |  2   2011          .        9 |
     11. |  2   2012         22       11 |
     12. |  2   2013          .       11 |
         +-------------------------------+
    PS and FWIW: "wanna" is teenspeak or textspeak for "want to" and not yet standard English, so you should want to avoid it in your papers. If you know that already, you should still want to avoid it on Statalist because people a bit like me tend to answer the questions.

    Comment

    Working...
    X