Hello all
This feels very basic but I'm struggling with recoding a variable to remove very high hourly wages (top 0.1% of values) and recode missing data as missing.
I've done this
gen hourpay_1 = HOURPAY1
drop if hourpay_1<0
drop if hourpay_1>98
gen hourpay_5 = HOURPAY5
drop if hourpay_5<0
drop if hourpay_5>99.9
But then the very high rates and the missing data are removed from the original as well as the duplicate variables. Can anyone tell me why that happens? Is there a way to avoid that happening? And if there is not, how else can I recode hourpay_1 to remove both the values <0 and >98?
I've started with this to exclude the <0s, which has worked
gen hourpay_1 = HOURPAY1 if HOURPAY1 > 0
But now I'm trying to also remove the very high values and getting nowhere.
recode hourpay_1 >98 = .
unknown el >98 in rule
recode hourpay_1 if hourpay_1 >=98
rules expected
gen hourpay_1a = hourpay_1 if hourpay_1 < 98
98 invalid name
It feels like I'm missing a very basic trick but would be very grateful for some assistance!
Thanks so much
Jules
This feels very basic but I'm struggling with recoding a variable to remove very high hourly wages (top 0.1% of values) and recode missing data as missing.
I've done this
gen hourpay_1 = HOURPAY1
drop if hourpay_1<0
drop if hourpay_1>98
gen hourpay_5 = HOURPAY5
drop if hourpay_5<0
drop if hourpay_5>99.9
But then the very high rates and the missing data are removed from the original as well as the duplicate variables. Can anyone tell me why that happens? Is there a way to avoid that happening? And if there is not, how else can I recode hourpay_1 to remove both the values <0 and >98?
I've started with this to exclude the <0s, which has worked
gen hourpay_1 = HOURPAY1 if HOURPAY1 > 0
But now I'm trying to also remove the very high values and getting nowhere.
recode hourpay_1 >98 = .
unknown el >98 in rule
recode hourpay_1 if hourpay_1 >=98
rules expected
gen hourpay_1a = hourpay_1 if hourpay_1 < 98
98 invalid name
It feels like I'm missing a very basic trick but would be very grateful for some assistance!
Thanks so much
Jules
Comment