Hi all,
I’m trying to generate a new variable that tells me whether or not each participant in the dataset had an elevated value for a test. The threshold for elevation is specific to age group (30s, 40s, 50s, 60+) and gender. E.g. if you’re 51 and male, an elevated value would be 0.6 while if you’re 40 and female it may be 0.5.
I recoded my continuous age variable into groups, with the variable agegrp:
0 = less than 40
1 = 40 –less than 50
2 = 50 – less than 60
3 = 60+
gender
male = 1
female = 2
I tried to start with the men and combine at least the 4 different options for what is an elevated value for each group with the idea that I could add on for women:
gen elevated_value = gender==1 & agegrp==0 & test_value > 0.553|gender==1 & agegrp==1 & test_value > 0.626|gender==1 & agegrp==2 & test_value > 0.687|gender==1 & agegrp==3 & test_value > 0.791
However, this doesn’t seem to be working. I just want to create a variable that tells me that the test value is high (or not) for that person, given the gender and age category. Any ideas? Thanks in advance!
I’m trying to generate a new variable that tells me whether or not each participant in the dataset had an elevated value for a test. The threshold for elevation is specific to age group (30s, 40s, 50s, 60+) and gender. E.g. if you’re 51 and male, an elevated value would be 0.6 while if you’re 40 and female it may be 0.5.
I recoded my continuous age variable into groups, with the variable agegrp:
0 = less than 40
1 = 40 –less than 50
2 = 50 – less than 60
3 = 60+
gender
male = 1
female = 2
I tried to start with the men and combine at least the 4 different options for what is an elevated value for each group with the idea that I could add on for women:
gen elevated_value = gender==1 & agegrp==0 & test_value > 0.553|gender==1 & agegrp==1 & test_value > 0.626|gender==1 & agegrp==2 & test_value > 0.687|gender==1 & agegrp==3 & test_value > 0.791
However, this doesn’t seem to be working. I just want to create a variable that tells me that the test value is high (or not) for that person, given the gender and age category. Any ideas? Thanks in advance!
Comment