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
Count with nearstatHi all, My dataset is made up of gasoline stations located by latitude and longitude. These stations…
Generating new variable using subtractionHello! I have data on the year that employees joined a company, startyear. In order to figure out th…
Store r-class values and tabulate laterHello all, I am new to stata and my work is about medical data. My data are about diagnostic perfor…
Log Transformation Willingness to Pay DataI am working on a OLS meta regression with a Willingness to Pay (WTP) variable as dependend variable…
bubble chart for groupsHi, I am quite new to stata and want to create a bubble chart for visualizing frequencies within a …
Subscribe to:
Post Comments (Atom)
0 Response to Generate a count variable capturing # of times a value occurs in categorical variables
Post a Comment