Announcement

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

  • relative value for panel data

    hello dear all,

    I have panel data of 143 countries over the 49 years.
    I want to compute the relative value of one of my variables.
    I compute in this way, but not so sure if I did correctly or not. I try to chack also manually in excel.
    I appreciate receiving your assistance.



    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double ifscode float year double WUI_sum
    111 1973           .0897666
    111 1974 .28516949999999996
    111 1975 .48200679999999996
    111 1976           .3596399
    111 1977 1.0571842999999999
    111 1978 .19876069999999998
    111 1979  .5083416000000001
    111 1980 .24863100000000002
    111 1981           .3621824
    111 1982           .3713493
    111 1983           .3962155
    111 1984            .192419
    111 1985           .0839913
    111 1986 .21242709999999998
    111 1987           .3327374
    111 1988           .7352632
    111 1989 .36565369999999997
    111 1990 .39529499999999995
    111 1991           .1536587
    111 1992           .2734836
    111 1993  .5693062999999999
    111 1994           .2580359
    111 1995           .2924072
    111 1996           .1409335
    111 1997           .0495638
    111 1998           .4398425
    111 1999           .2346321
    111 2000           .2538247
    111 2001           .9892922
    111 2002            1.07912
    111 2003          1.2123401
    111 2004           .3570366
    111 2005 .49987200000000004
    111 2006 .23886079999999998
    111 2007           1.094794
    111 2008           .6031295
    111 2009          1.0202793
    111 2010  .8268708999999999
    111 2011           .7264667
    111 2012          1.5249123
    111 2013           .8904299
    111 2014           .5881687
    111 2015           1.073512
    111 2016  .8585571000000001
    111 2017           .7434678
    111 2018  .7691144999999999
    111 2019          2.1541754
    111 2020 1.4796038999999999
    111 2021 .38883500000000004
    112 1973           .0855359
    112 1974 .38107559999999996
    112 1975           .8089789
    112 1976 1.0808285999999998
    112 1977           .3710501
    112 1978          1.0868924
    112 1979  .9693126999999999
    112 1980 .46875239999999996
    112 1981           .3194212
    112 1982 .36219169999999995
    112 1983           .8144914
    112 1984                  0
    112 1985 .06320909999999999
    112 1986           .2062234
    112 1987                  0
    112 1988           .5320132
    112 1989           .6230532
    112 1990           1.230429
    112 1991           .6524292
    112 1992           .3223508
    112 1993           .3112551
    112 1994 .08992339999999999
    112 1995           .1008928
    112 1996 .44899579999999995
    112 1997           .7623446
    112 1998  .6506400999999999
    112 1999           .5433545
    112 2000           .2850048
    112 2001           .5955098
    112 2002 .27691750000000004
    112 2003           .8814714
    112 2004           .6360688
    112 2005           .6806401
    112 2006           .5955746
    112 2007           .8178505
    112 2008           .7105001
    112 2009           1.818801
    112 2010 1.4819679000000001
    112 2011 1.3387272000000001
    112 2012 1.6197735999999998
    112 2013 1.2138284000000001
    112 2014  .9520833000000001
    112 2015          1.9084387
    112 2016          3.9415905
    112 2017          1.8996527
    112 2018           2.433672
    112 2019          4.7189962
    112 2020 3.4935945000000004
    112 2021          2.0885071
    117    .                  .
    118    .                  .
    end
    and I compute :
    Code:
    gen averageSD_rest=.
    
     
    
    levels ifscode , local(values)
    
    levels year, local(year)
    
    foreach j of local values  {
    
    foreach y of local year    {
       summarize WUI_sum  if  year ==`y' &  ifscode != `j', meanonly            
    
       replace averageSD_rest = r(mean) if ifscode == `j' & year==`y' & WUI_sum  !=.
    
    }
    }
    Code:
    gen wui_relative=WUI_sum-averageSD_rest

    Many thanks in advance for your assistance and any comments.

    Best regards,
    Last edited by Khati Zolfaghari; 14 Nov 2023, 17:37.

  • #2
    Click image for larger version

Name:	photo_2023-11-15_03-56-55.jpg
Views:	2
Size:	89.8 KB
ID:	1733912 I want to compute the relative value of my variable.
    Many thanks in advance. I hope I did correct.
    Attached Files

    Comment

    Working...
    X