Announcement

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

  • Adding monthly observations to start and end date

    Hi everyone,

    does anyone know how to add monthly observations to the yearly ones ?

    I have variables "datestartrole" (Start of work) and "dateendrole" (End of work). For example, 01jul2010 - 01may2012.

    How can I add monthly observations to all such variables so that every month of the year is displayed ?

    Thank you very much,
    Vasylisa

  • #2
    If you want code, it is always best to post example data. I will show you code based on what I imagine your data to be. If I have not successfully read your mind, it may not work.

    Code:
    gen start_month = mofd(datestartrole)
    gen end_month = mofd(dateendrole)
    expand end_month - start_month + 1
    by start_month, sort: gen month = start_month + _n - 1
    format month start_month end_month %tm
    In the future, to avoid guesswork about what your data looks like, whenever you request advice on coding, always show an example of your data. The helpful way to do that is with the -dataex- command. (Note: -list- output, HTML tables, and above all, screen shots are not helpful.) If you are running Stata version 15.1, -dataex- is part of your official installation. If running something earlier, then you have to run -ssc install dataex- to install it. Either way, run -help dataex- to read the simple instructions for using it. By always using -dataex- when you seek advice on coding you will maximize the chances that you will get a helpful and timely response.



    Comment


    • #3
      Thank you very much, Mr. Schechter. It is a great help for me. I will try out the code.
      I will show examples in my future posts.

      Comment

      Working...
      X