Hi, I want to create dummy variables based on the median. Sometiems I do that based on quartile and tercile. I do the following
1. This will create a yearly median variable and median dummy
egen ana= xtile(num), n(2) by(fyear)
gen num_dummy = cond(missing(ana), ., (ana>1))
2. This will create a yearly tercile variable and a dummy based on top tercile
egen ana= xtile(num), n(3) by(fyear)
gen num_dummy = cond(missing(ana), ., (ana>2))
3. This will create a yearly quartile variable and a dummy based on top quartile
egen ana= xtile(num), n(4) by(fyear)
gen num_dummy = cond(missing(ana), ., (ana>3))
Though I checked that the codes give me the correct answer even if I calculate them by using slightly different code, I want to make sure from the expert that I am doing it correctly.
So, experts, could you please tell me whether I am doing things correctly or not?
Related Posts with Median, Tercile and Quartile
PSMATCH2: one to one matchingI would like to get a matched sample by running the code below Code: psmatch2 y x1 x2, logit common…
Competing risks regression and time-varying covariatesDear Stata Listers, I wish to evaluate the effect that local recurrence has on the risk of ocular m…
table checking balance across covariates for two groups.Hi all, I am trying to create a small table where I test if covariates are balanced across two grou…
Different colors for two groups of bars in a bar chartDear all, I am trying to make a bar chart that shows mean value of a variable (attitudes toward immi…
WRDS / IBES - Get the right data into STATAHello, forgive me for the seemingly stupid question but this is my first empirical research and my …
Subscribe to:
Post Comments (Atom)
0 Response to Median, Tercile and Quartile
Post a Comment