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
Plotting estimates from -ir- and -iri-Dear Statalisters, Is there a way to plot the IRR and 95%CI after using either Code: ir or Code: …
Losing data when controlling for variables, and how to decide on best model?Hi all I've a trying to estimate the effect of 'economic equality' (X) on whether you want to have …
ppml_panel_sg and r(3203)Hello, I am analyzing the impact of tariffs on trade using ppml_panel_sg, and an r(3203) error some…
How to deal with categorical variable (a group of dummy vars) in Multilevel model?Hi there, I'm working on a dataset with individual-level and school-level variables using multileve…
Dummies on filter events scores and frequency Hello stata users, I am having a panel of groups and need to filter them to positive and not posi…
Subscribe to:
Post Comments (Atom)
0 Response to Counting number of categories in a variable by group
Post a Comment