Announcement

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

  • Creating one variable

    Hi all,

    I am going to create a variable in a way that variable in -SIMMIdt in year 2015 - SIMMIdt in year 2010 in the same region.
    for example: .01467756 -.01926798=

    Code:
    clear
    input int year byte region float SIMMIdt
    2010 1   .01926798
    2015 1   .01467756
    2010 2  .018267224
    2015 2  .014039835
    2010 3   .02406379
    2015 3  .022580145
    2010 4  .010038483
    2015 4 .0091869775
    2010 5   .00555628
    2015 5   .00540444
    2015 6  .008160894
    2010 6  .010712284
    2015 7  .012789745
    2010 7  .015284938
    end

    Any ideas appreciated.

    Cheers,
    Paris


  • #2
    On the assumption that all observations have either year == 2015 or 2010, no other values:
    Code:
    assert inlist(year, 2010, 2015)
    by region (year), sort: gen wanted = SIMMIdt[2] - SIMMIdt[1]

    Comment


    • #3
      Thank you so much Prof Clyde,

      It worked perfectly.
      To drop duplicates I used :
      Code:
      input int year byte region float(SIMMIdt wanted)
      2010 1   .01926798   -.004590418
      2015 1   .01467756   -.004590418
      2010 2  .018267224  -.0042273887
      2015 2  .014039835  -.0042273887
      2010 3   .02406379   -.001483647
      2015 3  .022580145   -.001483647
      2010 4  .010038483  -.0008515054
      2015 4 .0091869775  -.0008515054
      2015 5   .00540444 -.00015184004
      2010 5   .00555628 -.00015184004
      2010 6  .010712284    -.00255139
      2015 6  .008160894    -.00255139
      2015 7  .012789745   -.002495193
      2010 7  .015284938   -.002495193
      end
      
      
      
      bysort wanted: keep if _n==_N

      Comment

      Working...
      X