Dear Stata users,
I have a panel data set with 14 string variables each of which indicates whether this type of service is provided (one variable per service), and if it is, by what means.
These variables can take values "NP", "Comb", "Other gov", "Own gov", "Private", "RDC".
I would like to create a count variable "total" indicating the number of services provided for each observations. This variable would most likely count the number of "NP"s in all 14 variable for a given id-year, and subtract that from 14 (because 14 is the maximum number of services provided, subtracting the number of those not provided would give me what I need). I have not been able to find any way of doing this in Stata, so I wanted to ask for advice. Please let me know if this information is insufficient or unclear.
Thank you!
Related Posts with Generate a count variable capturing # of times a value occurs in categorical variables
Help generating this type of plotHey all, I need some assistance regarding the appropriate data shaping and plot type to generate thi…
Endogeneity correction via Gaussian Copulas - generating normal CDF of a non-normal empirical distribution functionDear Stata experts, I am a passionate passive follower in the forum, you guys helped me a lot in th…
Post estimation models for latent class analysesI recently ran a latent class analysis for my choice experiment data using the "lclogit" command. I …
Lag of variable with condition of not being misssingI want to create the lag of a variable with one caveat. If it is missing, I want to use the previous…
Monte Carlo SimulationHi all, I want to be able to run a Monte Carlo simulation for an econometrics assignment that I hav…
Subscribe to:
Post Comments (Atom)
0 Response to Generate a count variable capturing # of times a value occurs in categorical variables
Post a Comment