Hi all,
I am working on the following set of data :
clear
input byte(id time)
1 1
1 2
1 3
1 4
2 1
2 2
2 3
3 1
3 2
3 3
3 4
4 1
4 2
5 1
5 2
5 3
6 1
6 2
7 1
7 2
7 3
8 1
8 2
8 3
8 4
9 1
9 2
9 3
9 4
10 1
10 2
10 3
end
I wish to get the value of the maximum of the variable "time" for each "id". For example :
- for id "1" the max value of time is 4.
- for id "2" the max value of time is 3.
- for id "3" the max value of time is 4.
- for id "4" the max value of time is 2 ect...
Then I would like to get the number of occurrence of every maximum value for the time variable. In the example above :
- The number of occurrence of maximum time value = 1 is 0.
- The number of occurrence of maximum time value = 2 is 2 (occurres for id = 4 and id = 6).
- The number of occurrence of maximum time value = 3 is 4 (occurres for id = 2, id = 5 id = 7 and id = 10).
- The number of occurrence of maximum time value = 4 is 4 (occurres for id = 1, id = 3 id = 8 and id = 9).
Do you know a Stata script that could automatize this process ?
Thank you so much for your help.
Best regards,
Al.
I am working on the following set of data :
clear
input byte(id time)
1 1
1 2
1 3
1 4
2 1
2 2
2 3
3 1
3 2
3 3
3 4
4 1
4 2
5 1
5 2
5 3
6 1
6 2
7 1
7 2
7 3
8 1
8 2
8 3
8 4
9 1
9 2
9 3
9 4
10 1
10 2
10 3
end
I wish to get the value of the maximum of the variable "time" for each "id". For example :
- for id "1" the max value of time is 4.
- for id "2" the max value of time is 3.
- for id "3" the max value of time is 4.
- for id "4" the max value of time is 2 ect...
Then I would like to get the number of occurrence of every maximum value for the time variable. In the example above :
- The number of occurrence of maximum time value = 1 is 0.
- The number of occurrence of maximum time value = 2 is 2 (occurres for id = 4 and id = 6).
- The number of occurrence of maximum time value = 3 is 4 (occurres for id = 2, id = 5 id = 7 and id = 10).
- The number of occurrence of maximum time value = 4 is 4 (occurres for id = 1, id = 3 id = 8 and id = 9).
Do you know a Stata script that could automatize this process ?
Thank you so much for your help.
Best regards,
Al.
Comment