Announcement

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

  • Combine two age group variables, tell stata to use youngest age

    Hi,
    I am a criminology student analysing survey data. I have two age grouped variables which I would like to combine in Stata:
    Age first viewed Movie type 1 (1 (0–4 years) 2 (5–9 years) 3 (10–13 years) 4 (14–15 years) 5 (16–17 years) 6 )18–20 years 7 (21–24 years) 8 (25–29 years) 9 (30–34 years) 10 (35–39 years) 11 (40+ years)
    Age first viewed Movie type 2 (same age categories as variable 1 above)
    I would like to combine these two variables, telling Stata that if a respondent has viewed both movie types, to record earliest age viewed of the two movie types - i.e. record the age of whichever one came first. In other words, if a respondent first viewed Movie type 1 at age 14–15 years, and viewed Movie type 2 at age 16–17 years, to record the age 14–15 years as this is the earliest age.
    At the end I would like one variable measuring the age respondents first viewed either type of movie, with the youngest age recorded if they viewed both types.
    Can anyone help? Thank you in advance!

  • #2
    Hi,
    for your question, try this command:
    Code:
    gen yourvar = min(age1, age2)

    Comment


    • #3
      Thanks very much, I'll give this a try

      Comment


      • #4
        Hello my name is deon

        I have my age 15, 16, 17, 18. But I will also like to show age range from 40 to 60. So that I can eventually place in a graph. But instead of having all numbers on my graph age 40 age 41 and so on. I am trying to see if it is possible to collapse the data to age range 40 – 60.
        Thank you

        HOW OLD |
        WHEN YOU |
        FIRST |
        STARTED | SEX OF RESPONDENT
        SMOKING? | 1 Male 2 Female | Total
        -----------+----------------------+----------
        Age 15 | 664 662 | 1,326
        Age 16 | 789 974 | 1,763
        Age 17 | 525 612 | 1,137
        Age 18 | 952 1,038 | 1,990
        -----------+----------------------+----------
        Total | 2,930 3,286 | 6,216

        Comment


        • #5
          #4 is a duplicate post. If interested, please follow https://www.statalist.org/forums/for...-varlist/page2

          Comment

          Working...
          X