Announcement

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

  • How to transform year of birth to age

    Dear All,

    Does anyone know the command for transforming year of birth to age?

    For example:

    . tab A1

    In what year |
    were you |
    born? |
    (record |
    numeric) | Freq. Percent Cum.
    -------------+-----------------------------------
    1950 | 1 0.05 0.05
    1951 | 1 0.05 0.11
    1952 | 1 0.05 0.16
    1953 | 1 0.05 0.22
    1954 | 3 0.16 0.38
    1955 | 3 0.16 0.54
    1956 | 6 0.32 0.86
    1957 | 5 0.27 1.13
    1981 | 15 0.81 90.56
    1982 | 9 0.49 91.04
    1983 | 17 0.92 91.96
    1984 | 10 0.54 92.50
    1985 | 16 0.86 93.36
    1986 | 19 1.03 94.39
    1987 | 12 0.65 95.04
    1988 | 10 0.54 95.57
    1989 | 10 0.54 96.11
    1990 | 6 0.32 96.44
    1991 | 10 0.54 96.98
    1992 | 6 0.32 97.30
    1993 | 9 0.49 97.79
    1994 | 6 0.32 98.11
    1995 | 10 0.54 98.65
    1996 | 11 0.59 99.24
    1997 | 7 0.38 99.62
    1998 | 6 0.32 99.95


    The numeric variable column (e.g. 1901, 1918, 1921...) all represents the year of birth. I need to change these numeric values to age (as of 2017).

    Do I have to recode every singly one of them? I.e. recode A1 (1950=67) (1951=68) ... (1998=19)


    Many thanks,

    Tommy
    Last edited by tommy chai; 12 Aug 2017, 08:39.

  • #2
    Does
    Code:
    gen age = 2017 - A1
    do what you want?
    Martyn

    Comment

    Working...
    X