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 .
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")
Your videos are fantastic. They helped me a lot. Please post more.
Thanks! This finally made me understand macros!
Thanks for your videos. Hope you will post more this year!
Excellent and very helpful!
Dear Sir,
May I ask why do we generate the local macro final_vars with `final_vars' `var'_world? Thank you.
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. :)
These are super helpful
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.
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!
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.
Thank you for your helpful tutorials, may you please do a tutorial on how to merge multiple datasets
Yes, I think I will do something soon. This seems to be quite the hot topic. :)
What is the problem with the followin command to draw a line graph?
*5. Draw Line graph
line `final_vars' date
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.
dear sir, we even cant hear your voice
Yes agreed, need to pump up the volume. xD I recorded this with 0 equipment... thanks for your feedback.
@@statastic please do notify us if you do have another video with audio. already subsrice you. thank you sir