Dear all,
Please take a look at the attached dummy dataset screenshot. How do I generate a variable "Number" which tells me the number of colours per district? For example, for district A, Number should be 2, as there are 2 colours - BLUE and PINK. Similarly, for District B, Number should be 3, as there are 3 colours overall - BLUE, PINK and RED.
The actual dataset has way more colours and districts than just a few.
Thanks in advance!
Related Posts with Counting number of categories in a variable by group
Generating a new variable with an if commandHi all, I have a series of 6 datasets - for ease of reference, let's call them 2015, 2016, 2017, 20…
confidence intervals on proportionHi there Apologies in advance if this has already been answered elsewhere. I have a dataset of many …
Help with my work!Hi everyone, I have some work I am really struggling with, I am only able to complete 1a) and the re…
Second legend StataI have a coefficient plot of the following form: Code: sysuse auto eststo reg_1: reg price mpg ests…
Fractional response model with balanced panel data and binary endogenous and instrumental-variable.Dear All, I am using balanced panel for the model where the dependent variable is a fraction. Both e…
Subscribe to:
Post Comments (Atom)
0 Response to Counting number of categories in a variable by group
Post a Comment