Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • BP Category

    Hello,
    I am relatively new to STATA.
    Can anyone kindly help me with the command to generate BP categories. I have sysbp and diabp and would want th generate the categories as follows;
    Normal BP =0 if sysbp<120 and diabp<80
    Elevated BP =1 if sysbp=120-129 and diabp<80
    Stage 1 HTN =2 if sysbp=130-139 or diabp=80-89
    Stage 2 HTN =3 if sysbp≥140 or diabp≥90

    I can't seem to figure out how to incorporate the and/or in the commands.
    Thanks in advance.

    Best regards
    Olumide

  • #2
    please read the FAQ which provides excellent advice on asking questions; I will assume here that you want one variable with 4 categories and labels (any of which you can, of course, change):
    Code:
    gen byte htn = 0
    replace htn = 1 if inrange(sysbp,120,129) & diabp<80
    replace htn = 2 if inrange(sysbp,130,139) | inrange(diabp,80,89)
    replace htn = 3 if (sysbp>=140 & sysbp<.) | (diabp>=90 & diabbp<.)
    la def htn 0 "normal" 1 "elevated" 2 "stage 1" 3 "stage 2"
    la val htn htn
    note that I have dealt with possible missing values only in the last statement - however, this way of setting up the code means that those with one or both sysbp and diabp missing will be coded as normal; you might not want that; instead you might want
    Code:
    gen byte htn = ,
    replace htn =0 if sysbp<120 & diabp<80
    in place of the first statement in the first code block above

    Comment


    • #3
      See http://biostat.mc.vanderbilt.edu/wik.../CatContinuous for 15 reasons why this is a bad idea.

      And FAQ Advice #18 for why the spelling is Stata,.

      Comment


      • #4
        Thanks Rich. This solves my problem perfectly. I will take your advice on reading the FAQ.
        Thanks Nick. Its Stata.
        One last thing. What would be the command to plot sysbp for age and sex using the cubic splines regression. Thanks

        Comment


        • #5
          Re #3. Normally I am as vociferous as Nick in bewailing the misguided practice of making categories out of continuous variables. And I do agree with Nick that there is no statistical justification for doing it here, for most purposes.

          However, these particular cutpoints represent the accepted ranges for these categories in current US medical practice, and these cutpoints are (unfortunately) widely used by health care providers in the US for decision making about treatment. So if the purpose of the project, for example, is to assess the extent to which US providers are adhering to "official" guidelines, then this categorization is necessary and appropriate. If, however, the purpose of the study is to learn something about how blood pressure is related to other patient attributes, biological or otherwise, using these categories is just throwing away information and statistical power, and also may introduce bias.

          By the way, if anyone is interested in seeing just how badly the use of guidelines like this can discard information and misclassify patients, see one of my earliest publications: Schechter CB, Adler RS. Bayesian Analysis of Diastolic Blood Pressure Measurement. Medical Decision Making (1988) 8:182-190. (In fairness, the technology used for clinical BP measurement today is better than what was widespread back then, and, were this study replicated today, the error variance component would be appreciably lower. Still, the paper provides, despite the somewhat intimidating title, an easy look at how badly cutpoints can perform.)

          What would be the command to plot sysbp for age and sex using the cubic splines regression. Thanks
          Not sure exactly what is intended here. But to do a cubic spline regression, you need to specify the number of knots in the cubic spline. Let's say, for illustration, we will use 4 knots.
          Code:
          mkspline age_spline = age, nknots(4) cubic
          regress sbp age_spline i.sex // PERHAPS OTHER VARIABLES AS WELL
          predict sbp_predicted, xb
          graph twoway line sbp_predicted age, by(sex) sort

          Comment


          • #6
            Thanks Clyde,

            After typing the second command (regress sbp age_spline i.sex), I get an error "age_spline ambiguous abbreviation"

            Comment


            • #7
              Sorry. That should have been age_spline* in the -regress- command.

              Actually, the graph is probably also not what you want. So I think starting over it looks like this:

              Code:
              mkspline age_spline = age, nknots(4) cubic
              regress sbp age_spline* i.sex // PERHAPS OTHER VARIABLES AS WELL
              predict sbp_predicted, xb
              by age, sort: egen sbp_margin = mean(sbp_predicted)
              graph twoway line sbp_margin, by(sex) sort
              Last edited by Clyde Schechter; 21 Oct 2018, 15:34.

              Comment

              Working...
              X