Hi all,
I have a range of test results & need to categorise them as low, normal, high, according to their normal ranges. I am looking to do this in an efficient way, & I'm not sure I've achieved that.
So far I have the following code which allows me to quickly change the ranges & use the lower "generate categorical variable" section for the various tests I have without changing anything:
I have 10+ tests I need to run this code for, with different normal ranges. I am looking for a way to make this more efficient than copying the above again & changing the test & ranges.
I am using Stata v14.2 for windows.
I would really appreciate any help/guidance on this.
Thanks,
Bryony
I have a range of test results & need to categorise them as low, normal, high, according to their normal ranges. I am looking to do this in an efficient way, & I'm not sure I've achieved that.
So far I have the following code which allows me to quickly change the ranges & use the lower "generate categorical variable" section for the various tests I have without changing anything:
Code:
*generate locals local test wbc local low 2.8 local high 7.7 *generate categorical variable gen `test'_cat=. replace `test'_cat=1 if inrange(`test',0,`low') replace `test'_cat=2 if inrange(`test',`low',`high') replace `test'_cat=3 if `test'>`high' & `test'!=.
I am using Stata v14.2 for windows.
I would really appreciate any help/guidance on this.
Thanks,
Bryony
Comment