ID | Year | Temp | NTemp | Temp - NTemp |
1 | 1990 | 10 | 12 | -2 |
1 | 1991 | 12 | 12 | 0 |
1 | 1992 | 14 | 12 | 2 |
2 | 1990 | 12 | 13 | -1 |
2 | 1991 | 13 | 13 | 0 |
2 | 1992 | 14 | 13 | 1 |
3 | 1990 | 13 | 14 | -1 |
3 | 1991 | 14 | 14 | 0 |
3 | 1992 | 15 | 14 | 1 |
I've a big dataset.
A simplified version is above.
Temp is temperature.
NTemp is normal temperature.
NTemp is calculated by averaging Temp in all years within a group.
I want to calculate deviation from normal temperature i.e. Temp-NTemp
Can you tell me how can I do the same in STATA using commands?
Thanks,
0 Response to How to calculate group-wise mean of VarX & subtract it from VarX?
Post a Comment