![]() ![]() If you did use a macro you will only have to go back to the line of code for the macro and remove the variable from the group. If you didn’t use a macro you will have to go back to every line of code and remove it. After reviewing your results you might decide to eliminate one of the variables. But wait, there is more.įor example, you might have to run numerous linear regressions, using several of the same predictor variables in each regression you run. Using a macro to represent several variables may not seem like a big deal and why bother with it. Note that each time you use the word continuous in a command line you must begin with the forward slanting single quote key ` (to the left of the 1 key on your keyboard) and finish with the backward slanting single quote key ‘ (to the right of the key on your keyboard). I then substitute the word continuous for the variable names in the the last lines. ![]() The command local tells Stata to use the word continuous to represent the variables educat, exper, wage, and age. The code below will perform the exact same actions as the code above. Using a macro allows me to simplify my work, which will reduce the potential for errors and keep it organized. In the first line of my code above, local continuous educat exper wage age, I am using the word “continuous” to represent the four variables educat, exper, wage, and age. If you remember from the previous article, the wages data set had four continuous variables. If you will be analyzing more than one data set then you might want to consider using the local command. If you plan on analyzing only one data set then the global command shouldn’t cause you any problems. The command local tells Stata to keep everything in the command line in memory only until the program or do-file ends. If you open another data set before exiting, the global macro will still be in memory. The command global tells Stata to store everything in the command line in its memory until you exit Stata. How to write a simple macro in StataĪ macro in Stata begins with the word “global” or “local”. Writing macros in Excel can be long and involved. Please note that a macro in Stata is not the same as a macro in Microsoft Excel. In Stata this process is known as a macro. Stata allows you to use a single word, such as “continuous”, to represent many other words. Let’s look at the first line from above: local continuous educatexper wage age Let me explain how simple it is to understand. I admit it looks like a foreign language. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |