Announcement

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

  • period to period change

    Dear Stata users,

    The dataset I am working on is repeated measures data and it looks as below. I want to calculate period to period GFR change rather than change from "baseline".


    PHP Code:
    [CODE]
    Example generated by -dataex-. To installssc install dataex
    clear
    input long ID float
    (Visit_months Years_from_baselinedouble gfr int sbp
    1   0         0  53.7 127
    1   4  .3150685  43.8 117
    1  12  .9561644  50.4 125
    1  24 2.0027397  46.7 118
    1  36  3.016438  38.1 115
    1  48  3.978082  46.4 114
    1  60  4.994521    37 102
    1  72  5.991781    39 110
    1  84  7.008219  34.1 110
    1 100  7.282192  35.6 108
    1 101 10.432877  30.5 119
    1 103 13.238357  38.2 119
    2   0         0 121.7 114
    2   4  .3068493  87.2 114
    2  12 1.0109589  74.6 112
    3   0         0  79.6 146
    3   4  .3150685  71.2 122
    3  12 1.0109589  71.1 134
    3  24 2.0219178  68.7 141
    3  36  3.030137  46.5 144
    3  48 4.0054793  43.5 120
    4   0         0    54 159
    4   4  .3260274  58.8 129
    4  12  .9945205  58.7 113
    4  24 2.0054793  49.6 119
    4  36  3.005479  53.1 134
    4  48  4.076712  53.8 117
    4  60  5.008219    56 111
    4  72   6.00274  57.3 118
    4 100   6.19726  65.9 116
    4 101  9.052054  56.3 116
    end
    [/CODE

    I would really appreciate if anyone may help.

    Thanks a lot.


    Oyun

  • #2
    Code:
    by ID (Visit_months), sort: gen period_change_gfr = gfr - gfr[_n-1]
    by ID (Visit_months): gen rate_change_gfr = period_change_gfr/(Visit_months-Visit_months[_n-1])
    will give you both the absolute change in GFR (ml/min) over the period as well as the rate of change of GFR (ml/min per month).

    Comment


    • #3
      As always, thank you so much prof. Schechter.

      Comment

      Working...
      X