Hi there,
I'm creating a dummy variable that has multiple qualifiers and I'm unable to get it to work. I am using Stata 13.1 (with all updates installed).
My goal is to create a variable 'creatinineFI' that scores 1 if you fall outside a range and 0 if you are within it. For males (1) and females (0) the range is different.
The code I used is:
gen creatinineFI = (sexNP == 1 & creatinine <70 & creatinine >120 ///
| sexNP == 0 & creatinine <50 & creatinine >90) if !missing(creatinine)
This code does not produce any errors, however upon further examination all of the values of the dummy variable are 0, which is incorrect.
I would usually write (creatinine <70 | >120) when working with a range, however I'm not sure of the correct formatting when I add the sex qualifier as well.
I want the missing values to stay as missing in the dummy variable, hence the !missing expression.
Thank you,
Kerry
I'm creating a dummy variable that has multiple qualifiers and I'm unable to get it to work. I am using Stata 13.1 (with all updates installed).
My goal is to create a variable 'creatinineFI' that scores 1 if you fall outside a range and 0 if you are within it. For males (1) and females (0) the range is different.
The code I used is:
gen creatinineFI = (sexNP == 1 & creatinine <70 & creatinine >120 ///
| sexNP == 0 & creatinine <50 & creatinine >90) if !missing(creatinine)
This code does not produce any errors, however upon further examination all of the values of the dummy variable are 0, which is incorrect.
I would usually write (creatinine <70 | >120) when working with a range, however I'm not sure of the correct formatting when I add the sex qualifier as well.
I want the missing values to stay as missing in the dummy variable, hence the !missing expression.
Thank you,
Kerry
Comment