Announcement

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

  • Define age group.

    Dear all,

    My age range is 25-100.

    I want to work with this age range 25-65 years old.

    Is it correct to proceed as follows:

    recode variable 25/65=1, gen (new variable)?

    Many thanks.

  • #2
    -recode variable (25/65 = 1), gen(new_variable)- will give you a variable that takes the value 1 whenever variable falls between 25 and 65, and uses the original value of variable otherwise. That's probably not what you had in mind. [Note also the correct syntax for -recode-, which requires parentheses around the 25/65 = 1 rule.]

    Probably more useful is if new_variable is 1 when variable is between 25 and 65, and 0 otherwise. The way to do that is:

    Code:
    gen byte new_variable = inrange(variable, 25, 65) if !missing(variable)

    Comment


    • #3
      Dear Clyde Schechter,

      Thank you for your time and patience,

      Best regards.

      Comment

      Working...
      X