Hi guys,
Still a STATA rookie. I'm trying to figure out how to store a conditional median as a variable.
So I can get egen HL_cutoff = pctile( Day_max ), p(50) to work. But the trouble is I need it to be conditional - I need HL_cutoff to be the median of Day_max among people who have another variable, V1=0.
I've tried things like"
egen HL_cutoff = pctile( Day_max ), p(50) if V1==0
egen if V1==0 HL_cutoff = pctile( Day_max ), p(50)
EDIT: to be clear, I just what the computation of the median to be conditional. The variable should still apply to everybody.
What is the easiest way to do this?
Thanks!
Still a STATA rookie. I'm trying to figure out how to store a conditional median as a variable.
So I can get egen HL_cutoff = pctile( Day_max ), p(50) to work. But the trouble is I need it to be conditional - I need HL_cutoff to be the median of Day_max among people who have another variable, V1=0.
I've tried things like"
egen HL_cutoff = pctile( Day_max ), p(50) if V1==0
egen if V1==0 HL_cutoff = pctile( Day_max ), p(50)
EDIT: to be clear, I just what the computation of the median to be conditional. The variable should still apply to everybody.
What is the easiest way to do this?
Thanks!
Comment