Announcement

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

  • Generate Time-series Bar graph with monthly data (MY)

    I now only have two columns in my data Month Cases
    Jan 2000 50
    Feb 2000 79
    Mar 2000 90
    .... ....
    Dec 2013 80
    I want to generate a simple graph to show the change of monthly cases number

    and I do exactly the same things show in STATA lecture in youtube. Generate new variable Month2 and declare time-series.
    But every time i try to declare time-series.
    All I got is.... Month2
    3177m7
    3180m2
    3182m7
    3185m2
    3187m8
    3190m3
    ..... And I generate a bar graph, which i think shows the right trend of monthly cases change during the study period...
    but the x ais... is 3177m7 ..... instead of Jan 2000...
    I donnot know what is going on.
    I cant find answer anywhere...
    Please help me...
    Looking forward to your reply.

    Best regards,
    Jingwen from Uni Adelaide

  • #2
    Welcome to the Stata Forum / Statalist,

    Please read the FAQ. There you'll find information about sharing data/command/output.

    Dealing with dates demands following some steps. I recommend to clarify what you did exactly(I mean, the command as well as the output, for a given data), instead of informing that a variable was generated, time-series was declared, etc.

    This is the best approach to reap a helpful reply.
    Best regards,

    Marcos

    Comment


    • #3
      What you've done is tell Stata that a daily date has a monthly date format:

      Code:
      . di %tm mdy(1,1,2000)
       3177m7
      That change of display format won't change a date to another kind of date. To do that you need to convert explicitly as in

      Code:
      gen MonthDate = mofd(Month) 
      format MonthDate %tm
      or any other monthly format that suits.

      Comment


      • #4
        Thank you so much ! even though I still not 100% understand which step I did wrong. but~ it worked !!!! Sincerely appreciated !!!!!!!!!!!

        Comment


        • #5
          More at https://www.stata-journal.com/sjpdf....iclenum=dm0067

          Comment

          Working...
          X