Announcement

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

  • Age

    Hello Statalisters,
    I hope you are all doing good. I kindly ask for your help. I am working with a panel data. As below:


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double(division company) float(month offermonth age maxage)
    4273 1000001 371 109 262 495
    4273 1000001 372 109 263 495
    4273 1000001 373 109 264 495
    4273 1000001 374 109 265 495
    4273 1000001 375 109 266 495
    4273 1000001 376 109 267 495
    4273 1000001 377 109 268 495
    4273 1000001 378 109 269 495
    4273 1000001 379 109 270 495
    4273 1000001 380 109 271 495
    4273 1000001 381 109 272 495
    4273 1000001 382 109 273 495
    4273 1000001 383 109 274 495
    4273 1000001 384 109 275 495
    4273 1000001 385 109 276 495
    4273 1000001 386 109 277 495
    4273 1000001 387 109 278 495
    4273 1000001 388 109 279 495
    4273 1000001 389 109 280 495
    4273 1000001 390 109 281 495
    4273 1000001 391 109 282 495
    4273 1000001 392 109 283 495
    4273 1000001 393 109 284 495
    4273 1000001 394 109 285 495
    4273 1000001 395 109 286 495
    4273 1000001 396 109 287 495
    4273 1000001 397 109 288 495
    4273 1000001 398 109 289 495
    4273 1000001 399 109 290 495
    4275 1000001 399 400  -1 495
    4273 1000001 400 109 291 495
    4275 1000001 400 400   0 495
    4273 1000001 401 109 292 495
    4275 1000001 401 400   1 495
    4273 1000001 402 109 293 495
    4275 1000001 402 400   2 495
    4273 1000001 403 109 294 495
    4275 1000001 403 400   3 495
    4275 1000001 404 400   4 495
    4273 1000001 404 109 295 495
    4273 1000001 405 109 296 495
    4275 1000001 405 400   5 495
    4275 1000001 406 400   6 495
    4273 1000001 406 109 297 495
    4273 1000001 407 109 298 495
    4275 1000001 407 400   7 495
    4273 1000001 408 109 299 495
    4275 1000001 408 400   8 495
    4275 1000001 409 400   9 495
    4273 1000001 409 109 300 495
    4275 1000001 410 400  10 495
    4273 1000001 410 109 301 495
    4275 1000001 411 400  11 495
    4273 1000001 411 109 302 495
    4273 1000001 412 109 303 495
    4275 1000001 412 400  12 495
    4275 1000001 413 400  13 495
    4273 1000001 413 109 304 495
    4275 1000001 414 400  14 495
    4273 1000001 414 109 305 495
    4273 1000001 415 109 306 495
    4275 1000001 415 400  15 495
    4275 1000001 416 400  16 495
    4273 1000001 416 109 307 495
    4275 1000001 417 400  17 495
    4273 1000001 417 109 308 495
    4273 1000001 418 109 309 495
    4275 1000001 418 400  18 495
    4273 1000001 419 109 310 495
    4275 1000001 419 400  19 495
    4275 1000001 420 400  20 495
    4273 1000001 420 109 311 495
    4275 1000001 421 400  21 495
    4273 1000001 421 109 312 495
    4275 1000001 422 400  22 495
    4273 1000001 422 109 313 495
    4275 1000001 423 400  23 495
    4273 1000001 423 109 314 495
    4275 1000001 424 400  24 495
    4273 1000001 424 109 315 495
    4273 1000001 425 109 316 495
    4275 1000001 425 400  25 495
    4275 1000001 426 400  26 495
    4273 1000001 426 109 317 495
    4275 1000001 427 400  27 495
    4273 1000001 427 109 318 495
    4275 1000001 428 400  28 495
    4273 1000001 428 109 319 495
    4275 1000001 429 400  29 495
    4273 1000001 429 109 320 495
    4275 1000001 430 400  30 495
    4273 1000001 430 109 321 495
    4273 1000001 431 109 322 495
    4275 1000001 431 400  31 495
    4275 1000001 432 400  32 495
    4273 1000001 432 109 323 495
    4275 1000001 433 400  33 495
    4273 1000001 433 109 324 495
    4273 1000001 434 109 325 495
    4275 1000001 434 400  34 495
    end
    As you can see I calculated company's age (maxage) as the greatest value among divisions' for age variable (current month less offermonth). At the start of my analysis I just needed the gauge how old are the companies, but later in my analysis I will need to use first lag of companys' age. May I kindly ask you to tell help me with coding? In my sample, each month has the greatest value of age, and a lag would still be the maxage (495 in that case). Would it be the way to assign a month number on company level and deduct it from the maxage?

    More than greatful for your help.

    Best,
    RafaƂ

  • #2
    How about this?
    Code:
    by company, sort: egen origin_month = min(offermonth)
    gen current_age = month - origin_month

    Comment


    • #3
      Thank you Clyde. A lot.

      Comment

      Working...
      X