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
Merging datasets by inner joinHi, I have to merge three datasets by matching IDs as shown in the picture below. This is doable in…
test runHello! I apologize if some of the questions in this post seem simple, but this has to do with my the…
xtreg fe versus areg robust errors?Hello! I apologize if some of the questions in this post seem simple, but this has to do with my the…
Expanding DatasetHi everyone, I am trying to expand a dataset that looks like this: Dataset A contract_id region_…
When I import csv.file, some variables are not recognizedWhen I import csv.file, some variables are not recognized (?) but appear in the first some cells lik…
Subscribe to:
Post Comments (Atom)
0 Response to Creating an eligibility criteria through a counting variable
Post a Comment