I am trying to complete a homework assignment for a coding class where I have to "use bpsystol and bpdiast and JNC 7 report to create a categorical variable for bp_group: normal, pre-hypertension, stage 1, stage 2."
Category | Systolic BP (bpsystol) | Diastolic BP (bpdiast) |
Normal | < 120 | < 80 |
Pre-hypertension | 120 <= bpsystol < 140 | 80 <= bpdiast < 90 |
Stage 1 | 140 <= bpsystol < 160 | 90 <= bpdiast < 100 |
Stage 2 | bpstol >= 160 | bpdiast >=100 |
My most recent attempt used:
gen bp_group=.
replace bp_group = 1 if (bpsystol < 120) | (bpdiast < 80)
replace bp_group = 2 if (inrange(bpsystol, 120, 139)) | (inrange(bpdiast, 80, 89))
replace bp_group = 3 if (inrange(bpsystol, 140, 159)) | (inrange(bpdiast, 90, 99))
replace bp_group = 4 if (bpsystol >= 160) | (bpdiast >= 100)
replace bp_group = . if bpsystol == . | bpdiast == .
When I used tabstat to check my work, it produced this:
Array
So, the minimum boundary is not being followed in my code. I'm not sure what I'm doing wrong/missing. Please help!
0 Response to Creating categorical variables for hypertension
Post a Comment