Let's say we have a dataset a:
I want to create five dummy variables for quintiles of a, namely a1, a2, a3, a4, a5.
My code is:
Then, I list a1, a2, a3, a4, a5, the result is for a1, all equal 1, but for other variables, all equal 0, which is not I want.
Can someone tell me where is the problem? Thanks in advance.
Code:
use https://stats.idre.ucla.edu/stat/stata/examples/kirk/cr4, clear
My code is:
Code:
tabdisp order a, cellvar summarize a, detail gen byte a1=a<=r(p20) gen byte a2=a> r(p20) & a<=r(p40) ...... gen byte a5=a> r(p80) & a<=r(p100)
Can someone tell me where is the problem? Thanks in advance.
Comment