Hello!
I am trying to create a categorical variable (Y/N) when another variable measuring proportions is greater than or equal to 0.96, using operator "=>". However, Stata only marks proportions that are greater than 0.96, skipping those that are equal to 0.96:
*I also found that this problem does not appear when using more decimals (using 7 decimals below):
* cutoff with more decimals:
gen cutoff="y" if rand_moredec>= .9609721
Can someone explain why Stata does not recognize >=0.96, or tell me where my error is?
I am trying to create a categorical variable (Y/N) when another variable measuring proportions is greater than or equal to 0.96, using operator "=>". However, Stata only marks proportions that are greater than 0.96, skipping those that are equal to 0.96:
clear* cutoff with 2 decimals:
set obs 1000
set seed 2
gen rand_2decimals = runiformint(0, 100)/100* Notice 8 observations with value 0.96 that were not marked "Y".
gen atorabove96 = "Y" if rand_2decimals >=.96
sort rand_2decimals
*I also found that this problem does not appear when using more decimals (using 7 decimals below):
* cutoff with more decimals:
gen rand_moredec = runiform()* I can even create another categorical variable from a cutoff to 7 decimals, and Stata will correctly include the case with a value exactly equal to the cutoff:
gen atorabove96_more = "Y" if rand_moredec >=.96
sort rand_moredec
gen cutoff="y" if rand_moredec>= .9609721
Can someone explain why Stata does not recognize >=0.96, or tell me where my error is?
Comment