I'm trying to create a loop such that for each set of 4 through 6 a unique id (starting at 1, ending at N) is assigned for all those values inside the set, regardless of the name of that row. Example data:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str3 name byte(tau id) "AAA" 4 1 "AAA" 5 1 "AAA" 6 1 "AAA" 4 2 "AAA" 5 2 "AAA" 6 2 "AAA" 4 3 "AAA" 5 3 "AAA" 6 3 "BBB" 4 4 "BBB" 5 4 "BBB" 6 4 "CCC" 4 5 "CCC" 5 5 "CCC" 6 5 "CCC" 4 6 "CCC" 5 6 "CCC" 6 6 end
etc. Data is sorted like this. The variable ID here is manually assigned for sake of example, but in the real dataset it is about 350,000 observations.
I've tried both
Code:
foreach
Code:
forvalues
Code:
levels
Thanks in advance,
Bas de Kruijf
0 Response to Creating a loop that loops around a set of values of a variable
Post a Comment