Announcement

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

  • Birthyear

    Hi

    I have a variable firstbirth_cmc how I can get the birthyear from this like 1980 etc

    firthbirth_cmc
    1147
    1153
    1322
    1149
    1100
    1301


    dataex

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float firthbirth_cmc
    1147
    1153
    1322
    1149
    1100
    1301
       .
    1268
    1081
    1103
    1384
    1310
    1194
    1153
    1289
    1014
    1099
    1199
    1346
    1273
       .
       .
    1371
    1258
    1181
       .
       .
       .
    1245
       .
       .
    1235
    1172
    1314
    1284
       .
       .
    1385
    1349
       .
    1220
       .
    1323
    1317
       .
    1097
    1166
       .
    1248
    1381
    1330
       .
    1263
    1162
    1031
    1203
    1156
       .
    1233
    1107
    1099
       .
       .
    1243
       .
    1225
    1250
    1261
       .
    1262
    1293
    1341
    1316
    1264
    1369
    1230
    1341
    1276
    1328
    1304
       .
       .
    1085
    1206
       .
       .
    1385
       .
    1273
    1241
    1315
       .
    1239
    1363
    1317
    1282
       .
    1326
       .
    1255
    end
    ----------



  • #2
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input int firthbirth_cmc
    1147
    1153
    1322
    1149
    1100
    1301
    end
    
    gen mdate = tm(1899m12) + firthbirth_cmc
    format mdate %tm
    gen birthyear = year(dofm(mdate))

    Comment


    • #3
      thanks

      but how you pickup this number 1899m12

      Comment


      • #4
        https://demographicestimation.iussp....ry-month-codes

        This extended example and alternative method may help:

        Code:
        clear
        input int firthbirth_cmc
        1147
        1153
        1322
        1149
        1100
        1301
        -1
        0
        1
        1486 
        end
        
        gen mdate = tm(1899m12) + firthbirth_cmc
        format mdate %tm
        gen birthyear = year(dofm(mdate))
        
        gen BY = 1899 + ceil(firthbirth_cmc/12)
        
        list 
        
            +--------------------------------------+
             | firthb~c     mdate   birthy~r     BY |
             |--------------------------------------|
          1. |     1147    1995m7       1995   1995 |
          2. |     1153    1996m1       1996   1996 |
          3. |     1322    2010m2       2010   2010 |
          4. |     1149    1995m9       1995   1995 |
          5. |     1100    1991m8       1991   1991 |
             |--------------------------------------|
          6. |     1301    2008m5       2008   2008 |
          7. |       -1   1899m11       1899   1899 |
          8. |        0   1899m12       1899   1899 |
          9. |        1    1900m1       1900   1900 |
         10. |     1486   2023m10       2023   2023 |
             +--------------------------------------+
        Last edited by Nick Cox; 10 Oct 2023, 19:00.

        Comment

        Working...
        X