Stata Basics #7: How to Use Local Macros in Stata (using COVID-19 data)

Поділитися
Вставка
  • Опубліковано 15 вер 2024
  • We download and prepare data on the worldwide COVID-19 pandemic to create line graphs. I show how local macros can be used to create flexible variable lists that you can reference, e.g. to loop over. (Unintendedly) I also show how to identify and fix errors while coding.
    Data source: ourworldindata...
    Special thanks to Dr. Hannah Ritchie for compiling the data. You can follow her on / _hannahritchie .

КОМЕНТАРІ • 18

  • @Burak_verner
    @Burak_verner 3 місяці тому +1

    Excellent video! A short contribution: Instead of the 5 lines from 13 to 17, one line of command gets the job done: g newdate=date(date,"YMD")

  • @TheGeoeconomicsGuy
    @TheGeoeconomicsGuy 2 роки тому +1

    Your videos are fantastic. They helped me a lot. Please post more.

  • @edoardocattaneo4279
    @edoardocattaneo4279 Рік тому +1

    Thanks! This finally made me understand macros!

  • @plokijuh5830
    @plokijuh5830 3 роки тому +1

    Thanks for your videos. Hope you will post more this year!

  • @jerryho6120
    @jerryho6120 Рік тому

    Excellent and very helpful!

  • @MissSunny426
    @MissSunny426 3 роки тому +1

    Dear Sir,
    May I ask why do we generate the local macro final_vars with `final_vars' `var'_world? Thank you.

    • @statastic
      @statastic  3 роки тому

      Hi Ziqing, we do this to define which variables should be shown eventually in the line graph. Again, it's one way for being more lazy while making the code more flexible. :)

  • @brzydkareka
    @brzydkareka 3 роки тому +1

    These are super helpful

  • @tiveavorn7408
    @tiveavorn7408 2 роки тому

    Hello author.
    I follow your vdo instruction and practice until the end. it was good but at the end to draw the line it seems something wrong or different. The total death world seems not appear. Can help check me out. I used the data as 14 Sep 2022.

  • @Thejohnster1012
    @Thejohnster1012 3 роки тому

    great vid, but I am confused, what stops the final date truncation code from continually dropping 5 extra days each time you run it? as of course after the first time the max date is now 5 days shorter than it was. Thanks!

    • @statastic
      @statastic  3 роки тому

      That's because when we run the entire do file, it always loads the full data set in the beginning, so that only 5 days are dropped in total.

  • @elisamasiakwala3168
    @elisamasiakwala3168 4 роки тому +2

    Thank you for your helpful tutorials, may you please do a tutorial on how to merge multiple datasets

    • @statastic
      @statastic  4 роки тому +2

      Yes, I think I will do something soon. This seems to be quite the hot topic. :)

  • @mathewosmuke5495
    @mathewosmuke5495 3 роки тому

    What is the problem with the followin command to draw a line graph?
    *5. Draw Line graph
    line `final_vars' date

    • @statastic
      @statastic  3 роки тому

      Seems correct. Make sure to always run the entire do file though. For local macros, you cant just execute one line, because stata "forgets" a local macro as soon as it stops executing. So in the do editor, always go ctrl+a --> ctrl+d.

  • @zdavirandimuhammad1515
    @zdavirandimuhammad1515 2 роки тому

    dear sir, we even cant hear your voice

    • @statastic
      @statastic  2 роки тому

      Yes agreed, need to pump up the volume. xD I recorded this with 0 equipment... thanks for your feedback.

    • @zdavirandimuhammad1515
      @zdavirandimuhammad1515 2 роки тому

      @@statastic please do notify us if you do have another video with audio. already subsrice you. thank you sir