The problem is that the output always shows a little or above it. For example, there are 10000 observations. I don't get exact 6000 observations as 0 and 4000 observations as 1.
My code:
set obs 10000
gen a = uniform()
gen b = 0
replace b = 1 if a <= 0.40
What is wrong with this? Or is there any alternative?
Related Posts with How do you generate a categorical variable which takes on values 0 and 1 in 60% and 40% observations respectively?
Correlation structure of xtgee: tests of statistical significanceHello Statalisters, I'm using Stata 15.1. My question relates to the "xtgee" commands (in particula…
Stata 16 - Drop just variables and observationsI had Stata 14 and used drop _all command to drop just the variables/observations but keep all the r…
pinv vs luinv vs qrinvMata has these different functions for inverting square matrices. The matrices I am inverting are ab…
STATA: panel regression, xtset error, CUSIP8-code, string variableDear all, I am trying to complete a panel data regression with the individual and time identifiers:…
Looping with lagged valuesI'm new to Stata and would highly appreciate any help. I have a panel data. I want to implement for…
Subscribe to:
Post Comments (Atom)
0 Response to How do you generate a categorical variable which takes on values 0 and 1 in 60% and 40% observations respectively?
Post a Comment