AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Xlist command in stata12/29/2023 When you execute the displaycommand on its own, you will notice that it does not show any result. The backtick symbol can usually be found on the key with the tilda sign ( ~) on your keyboard. To display a local, we refer to its name after the displaycommand while enclosing it in a backtick ( `) and an apostrophe ( '). In subsequent examples, we will go with the first definition of local1 where it was defined as a mathematical expression equalling 10. If you wanted to store the above as a string, the expression would be enclosed in inverted commas without the equality sign. In this example, the local called local1 will store the value 10. The equality sign tells Stata to store the evaluated result of the expression we specify (instead of storing that expression as a string). Locals can be used to store mathematical expressions with a slight change in the syntax we are already familiar with. Unlike global macros, they will only work until the existing do-file is being worked on, and will not work if any other do-files are active. Local macros are also used for storing some piece of data, but they only work for the programme currently being run. In this manner, we can also save other (usually longer) directories once in their respective macros, and then reference them throughout our do-file without retyping them and still maintaining good readability. global datafolder “E:\ABC” use “$datafolder\analysis.dta”, clear If your datasets are stored in different folders, you can store the common part of their directory in a global. In case this method was to be replace with another one, or if more options needed to be added across multiple regressions, we would only have to change the global called ‘method’.įinally, globals can also be used to store file paths. We can define a macro that does this by defining it and calling it ‘robust’ (which is the option used alongside regression commands to get robust standard errors): global method robust reg price mpg weight, $robust In such a case, we would want robust standard errors to be calculated to address the problem. global ylist price reg $ylist $xlistĪnother use for globals comes up when we wish to apply some method to our analysis in order to deal with problems like, for example, hetersckedasticity. In this case, we can store price in a new macro called ylist and run the same regression as above. ![]() If need be, you can even store a single variable in a macro. We can also use the global to summarize the list of variables it contains: summarize $xlist In case you need to add or drop some control variables from the regressions, you would only have to edit the global rather every regression command. In cases where the list of our independent variables is very long and multiple regressions need to be run, using globals removes the need to write the list of variables over and over again, and also maintains the readability of our do-files. The above command is exactly the same as executing: reg price mpg weight But for those who don't feel like it, haven't installed yet, or are scared of the command line, here they are also.Note that when referring to an existing global, we precede its name with the $ symbol. You can see the list of available commands in your terminal by running php please list. Php please help make:user Available Commands
0 Comments
Read More
Leave a Reply. |