Save your do-files every few minutes as you write them. Computers crash, power goes out, stuff happens. The last command on your do-file will usually be “log close”. Note how logs are saved under the smcl extension.ĭo not forget to close your log before starting a new one. Log using “whateverpathyouwant:\pickanameforyourlog.smcl”, replace Starting a log is just a matter of adding a command at the top of your do-file that tells Stata to log, as well as where you want the log to be saved: Keeping a log means you can go back and look at what you did without having to do it again. Again, this is a general rule of thumb on Stata. One last comment about do files: if you double click a saved do file, it will not open for editing, but rather Stata will run that do-file, which can be a bit annoying… To reopen a do-file from a folder without executing the commands in it, right-click on it and select “edit” rather than “open”.Īlways keep a log. Finally, the command “set mem 15000” increases the memory available to Stata from your computer here we will need it as the size of the data set we downloaded from is larger than the 10mb allocated to data by default. The command “set more off” tells Stata not to pause or display the -more- message. The first, “clear”, is used to clear any previous dataset you may have been working on. These three commands are administrative commands that are quite useful to have at the beginning of a do-file.
You may wonder about the commands “clear”, “set more off” and “set mem 15000” in the screenshot example. To run a whole do-file, do not highlight any part of it and click on the “Execute Selection (do)” icon. In order to execute a number of commands rather than the whole do-file, simply highlight the ones you want to execute, and click on the “Execute Selection (do)” icon on the top of your do-file editor, at the far right.Īs you become more proficient with programming in Stata, you won’t need to try out commands anymore, and you’ll discover the joy of writing a do-file and having it run without a glitch. One simple way to do that and still have discipline about writing do-files is to write your do-file in stages, writing only a few commands before executing them, correcting mistakes as you go. For example, if you are not so familiar with a command, you may prefer to try it first. In the preliminary stages of your work, you may feel that a do-file is more hindrance than it is useful. To start a do-file, click on the icon that looks like a notepad on the top-left corner of your Stata viewer. Working from do-files lets other people see what you did if you ever need advice, it makes your work reproducible and it allows you to correct small mistakes somewhat painlessly.
This is a general advice that applies to any work you do on Stata. This way, if you make a mistake, you will not have ruined your entire dataset and you will not need to start again from scratch. You want to write the commands in a do-file, and then run it. Never clean a dataset by blindly entering commands (or worse, clicking buttons). Simply type “help” in the command window, followed by the name of the command you need help with and press the Enter key:
#Stata 13 graph commands manual#
Stata has a built in feature that allows you to access the user manual as well as help files on any given command. Whether this is your first time cleaning data or you are a seasoned “data monkey”, you might find some useful tips by reading more. Your first pass at a dataset may involve any or all of the following:
#Stata 13 graph commands software#
Stata is a good tool for cleaning and manipulating data, regardless of the software you intend to use for analysis.
It will very often be the first assignment of a research assistant and is the tedious part of any research project that makes us wish we HAD a research assistant. Creating a number of smaller subsets based on research criteriaĬleaning data is a rather broad term that applies to the preliminary manipulations on a dataset prior to analysis.Some useful tips before you get started.