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?
compare all the variables and get rid of the duplicated variables with different variable nameRecently I encountered an issue. I downloaded some data from the Census and Social Explorer and merg…
Unable to remove part of a string using strrpos ()Hello Stata users, I am using Stata/IC 15.1 and would like to remove the part of the first string v…
Sys gmmDear all, I have a panel data with 50 firms for 14 years. I want to estimate a system GMM model. Whe…
Generate new variable for one household member from observations from different household membersHi everyone! I'm fairly new to Stata & Statalist, so I apologize in advance if this question has…
Estimation sample not in memory - invalid syntaxHi everyone, I am using the command inequaly to compute the Gini coefficients with standard error e…
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