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?
How to drop the mtitle row in esttab ?In esttab, when I did not specify mtitle, STATA will automatically create a row for title similar to…
Reproducing "estat trendplots" linear-trends modelHello Statalist community, I am doing an analysis using a diff in diff methodology. As I use Stata …
help in generating count variableI am working on World Value Survey dataset. It consists of 5 waves and multiple countries in each wa…
Import multiple CSV filesHi I am trying to import multiple CSV files in a foreach loop. I saved the filenames in the local n…
Lineear mixed model/Repeated measure modelHi all, Can we add "timepoint" as a random slope or covariate in Linear mixed model? Here we have 8…
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