Dear forum,
I'm looking for a command similar to egen x = group(), but that also takes into account "spells" of observations. If we have :
egen x = group(var1 var2) would give
But I want to introduce the fact that individual number 4 is not following individual number 2 in the code, so that they belong to their own group. What I want is :
If an observation is not having the same var1 and var2 value than the previous one, it should have its own group, even if somewhere else very far in the dataset some other observation share the ssame var1 and var2 values. Can somebody help me achieve this?
I'm looking for a command similar to egen x = group(), but that also takes into account "spells" of observations. If we have :
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(id var1 var2) 1 3 4 2 3 4 3 5 6 4 3 4 end
egen x = group(var1 var2) would give
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(id var1 var2 x) 1 3 4 1 2 3 4 1 3 5 6 2 4 3 4 1 end
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(id var1 var2 y) 1 3 4 1 2 3 4 1 3 5 6 2 4 3 4 3 end
Comment