Hi all,
I have a question regarding building a counter as a new variable. If we consider the following table (I tried to use dataex, is this a correct use of it?):
input int(A B)
1 1 1
1 2 2
1 2 2
1 3 3
1 3 3
1 3 3
1 4 4
1 4 4
2 5 1
2 5 1
2 6 2
2 5 2
2 7 3
The first two variables are as given in my dataset. The third variable was added manually by me and is the variable I would like to create. It is supposed to show the number of unique counts of observations of variable B for a given variable A. For example: Variable A takes on the value 1 in the first eight observations. For these observations I would like to start a counter starting at 1 increasing incrementally for each new unique observation in variable B. The same process starts again with the next observation 2 in variable A. Again I would like to start a counter starting at 1 increasing incrementally for each new unique observation in variable B.
I would appreciate any help. Thank you.
I have a question regarding building a counter as a new variable. If we consider the following table (I tried to use dataex, is this a correct use of it?):
input int(A B)
1 1 1
1 2 2
1 2 2
1 3 3
1 3 3
1 3 3
1 4 4
1 4 4
2 5 1
2 5 1
2 6 2
2 5 2
2 7 3
The first two variables are as given in my dataset. The third variable was added manually by me and is the variable I would like to create. It is supposed to show the number of unique counts of observations of variable B for a given variable A. For example: Variable A takes on the value 1 in the first eight observations. For these observations I would like to start a counter starting at 1 increasing incrementally for each new unique observation in variable B. The same process starts again with the next observation 2 in variable A. Again I would like to start a counter starting at 1 increasing incrementally for each new unique observation in variable B.
I would appreciate any help. Thank you.
Comment