Dear all,
I'm having problems trying to generate a variable of count from a local and a loop. I need to count the number of times a subject has chosen number 2 across 6 variables. Then, to generate a variable with the number of times the option 2 has been selected.
Here my code:
(id: id of subject)
gen count2=.
local var var1 var2 var3 var4 var5 var6
foreach x of local var{
replace count2=count(`x'==2), by id
}
The result says: "error" unknown function count"
Any suggestions on this. I'd appreciate very much.
Best
Related Posts with Stata 13. Counting variable on loop.
GEE: results significant only with independent and exchangeable correlation structureHello there! I am trying to fit a GEE Poisson model on a panel dataset consisting of T=360 and N=30…
Obtaining marginal effects for all possible predictsHi everyone, I was wondering to know how can I combine the below four margins commands in a single o…
Extracting Year From DateHi, I have looked through older discussions and applied suggestions but my code returns an empty var…
DOS windows how to remove itDear all, My question will be quite simple I think but I just need to know if my wish could be real…
Variable types for regressionsCan anybody let me know what are the variable types on which a regression can run? …
Subscribe to:
Post Comments (Atom)
0 Response to Stata 13. Counting variable on loop.
Post a Comment