So I have a variable called "group" that takes several string values, its not unique thus many values get repeated. I want to calculate and assign the decile value for the variable "ownership" in a new column, but I want to do it for each "group" value.
For example, for the subsample with value AB32T for "group", I get want the decile calculations to be done for ownership. Then similarly for another value for "group", and so on for all value of "group".
So I wrote the code
This gives me an error that pctile may not be combined with by
I dont know how to proceed with it without a very long and arduous set of loops and appending. Can someone please help? Thank you.
For example, for the subsample with value AB32T for "group", I get want the decile calculations to be done for ownership. Then similarly for another value for "group", and so on for all value of "group".
So I wrote the code
sort group
by group: pctile ownership_decile = ownership, nq(10)
by group: pctile ownership_decile = ownership, nq(10)
I dont know how to proceed with it without a very long and arduous set of loops and appending. Can someone please help? Thank you.
Comment