I've been trying to create a "counting variable" that determines which observations meet the criteria based on their response to a list of variables.
Criteria:
Of the five variables, v1, v2, v3, v4, v5, eligible observations must have a value of >0 for at least 3 of the five variables. Each variable can have a value of ., 0, 1, 2, 3.
Attempts so far:
I've seen a previous thread counting the number of variables with a certain value, but this is not what I want. I need to determine the eligibility of an observation based on the values of a set of variables. Preferably I want to make a new variable that tells me how many variables that observation has >0 without creating a score of the numerical responses. Something like:
gen crit1 = 0
foreach x in v1 v2 v3 v4 v5 {
replace crit1 = crit1 + 1 if `x' >0
}
But I get a syntax error from this code. Any suggestions would be a huge help.
Related Posts with Creating an eligibility criteria through a counting variable
Accessing Files Created within SubprogramI am writing a Stata .ado program that performs the same subroutine many times. As such, I would lik…
How to weight the Gini coefficient decomposition?hi all, i want the Gini coefficient decomposition in Lerman-Yitzhaki's method. but "descogini" does…
Formatting datetime from one format to another in same variableHello everyone! I am facing some issues with my timestamp variable. The data that I have received f…
graph x-axis not legibleI used the code below to generate the attached plot but the values on the x-axis are not legible. Ki…
Color for figure: twoway (tsline)Hi all, I am making a figure and I would like to differentiate between colors. Specifically, I want…
Subscribe to:
Post Comments (Atom)
0 Response to Creating an eligibility criteria through a counting variable
Post a Comment