I want to categorize a variable on the basis of any set of cutpoints, not just percentiles. At the same time, since I have a panel, I want to do it for each point of time separately. In the following code and data, I categorize my firms on the basis of percentiles but when I use cutpoints(cpt) instead of nq() , it shows this error to me: option cutpoints() not allowed.
How can I categorize my firms in terms of cpt at each point of time? (Preferably, without using loops, because my data set is large)
How can I categorize my firms in terms of cpt at each point of time? (Preferably, without using loops, because my data set is large)
Code:
* sample generated data
clear all
input time firm value cpt
1 1 3 4
1 2 4 8
1 3 5 10
1 4 6 .
1 5 7 .
1 6 8 .
1 7 9 .
1 8 10 .
1 9 11 .
2 1 4 6
2 2 6 10
2 3 7 12
2 4 9 .
2 5 12 .
2 6 13 .
2 7 15 .
end
* finding quartiles for each time
egen perc = xtile(value), by(time) nq(4)

Comment