Stata has a collection of settings that can be applied using the set prefix command in the Command pane. This allows you to alter many of Stata’s default settings with regards to analysis. A short description of some of the more commonly used settings is shown below, along with how you apply the setting using commands. For settings that are turned on or off you simply add on or off to the command. For example - set graphics on or set graphics off. If you are looking for a setting not listed here, check out the help file using the command help set.
This allows you to set the maximum number of kilobytes that automatically loaded do-files may consume. The default is 1000 kilobytes. If you have a do-file you want Stata to hold in memory that is larger than 1000 kilobytes you use the command as follows:
set adosize #_of_kilobytes
This command is for Windows operating systems only. It allows you to set whether multiple graphs will open in tabs in the same window, or in completely separate windows. The default is off, which means they will open in separate windows. To change this to on (graphs open in tabs instead), use the command as follows:
set autotabgraphs on
Double buffering prevents windows from flickering when they are redrawn or resized. The default for this setting is on. If you have problems with results output being slow to load, you should try turning this off. To turn it off, use the following command:
set doublebuffer off
This sets the style of a decimal point, either comma or period. The default is a period. To change this to a comma, use the following command:
set dp comma
This controls what Stata does with empty cells. The default is to keep empty cells. To change this to drop empty cells, use the following command:
set emptycells drop
This controls whether Stata prints graphs. The default for this setting is on. When I am exporting a whole bunch of graphs I usually turn this off because it improves Stata’s processing time. To turn this off:
set graphics off
NOTE: Don’t forget to set graphics on at the end of a session, or Stata won’t show you any graphs you make in the next session!
This setting allows you to change the default confidence interval. Stata’s default is for a level of 95, which is equivalent to a p-value of 0.05. To change the confidence level to a chosen p-value, use the number 100–pvalue. For example, to change to a 0.1 p-value, use the following command:
set level 90
This setting will change the space between lines. You must specify the number of pixels you would like between lines. The default changes depending on your operating system and font choices. You can also change this setting using the menus.
For Windows – Edit > Preferences… > General preferences…
For Mac – Preferences > General preferences…
To set this using the command window, use the following command:
set linegap #
This setting is used to specify the screen width, in characters, for log file output. For the Results pane, the screen width will adjust when you make the pane bigger or smaller. To set your linesize, use the command:
set linesize #
This setting controls whether a log is opened in smcl or text format. The default for a full log is smcl, and command logs can only be opened in text. To change this setting, specify either smcl or text in the following command:
set logtype text
set logtype smcl
This controls the number of dialog boxes whose contents are remembered for the duration of a session. The default is for the content of the first 50 different dialog boxes to be remembered. To change this setting, use the following command:
set maxdb #
This setting controls whether Stata will pause output, display —more— and wait for a key to be pressed. The default for this setting is off, so Stata does not normally pause for a more message. To turn this on, use the following command:
set more on
This setting is commonly used when creating dummy datasets to test commands or analyses. If you are creating a new dataset you will need to set the number of observations before you start creating variables. Give the number of observations you would like in your dataset when using this setting. To set the number of observations, use the command:
set obs #
This setting is only available to Stata/MP licences. This allows you to change the number of processors Stata uses, within the bounds of your current licence. For example, if you have an MP4 licence you can set the number of processors to be used to 1; 2; 3; or 4, but not 5 because you have only purchased MP4. The default setting will be either the number of processors available on the computer, or the number of processors you have purchased, whichever is less. To change this setting use the following command:
set processors #
This sets the maximum number of commands stored by the History pane (previously called the Review pane). It can store up to 32,000 commands, and the default is to store 5,000. To change the number of commands stored, use the following command:
set reventries #
This setting controls which graph scheme is used to draw and colour graphs. A scheme contains many different graph settings that will be used as default settings by Stata. It allows you to control the look of your graphs without having to constantly edit each graph you create. Stata has several scheme files loaded, and you can also either make your own scheme file or download a scheme file made by someone else. To change the scheme file used, make sure the scheme file is saved in your personal ado filepath. For example, I have a scheme called Laura which is saved in my personal adopath, and to set the scheme for use in Stata I use the following command:
set scheme Laura
Use this setting to set the random seed number used for subsequent RNG (random number generator) commands. You should always set the seed before running a set of commands using RNG, so the results you get are reproducible by others. To set your seed, use the following command:
set seed #
This setting is Stata’s debugging command. If you set trace to on, Stata will print all of the behind-the-scenes computations to the Results screen. This setting is most commonly turned on when you are investigating a non-specific error that Stata has given you; or if you are debugging a user-written/personally-written program. Do not turn this on if you do not know what you are doing. If you are trying to debug a very long program script make sure to use set tracedepth as well. Without moderation from tracedepth this gives a lot of output to the Results screen, and it can significantly increase the time Stata takes to complete. If you have a very long program that takes days to complete and you are trying to debug, either step through it by slowly increasing tracedepth, or cut down the program into smaller manageable segments to test with trace. Additionally, make sure to have a log saving the output before you run anything through trace. There is often too much output for the Results screen to handle and it will overwrite earlier output with later output. Finally, make sure to turn trace back off when you are finished. To turn it on:
set trace on
and to turn in off:
set trace off
This is used alongside trace. By default, when the trace setting is on it will go all the way into each nested program and show you the output of each. So if the program you are running calls on a subprogram, which then calls on another subprogram, etc. the output you will see will include all of the subprograms. This can result in a huge batch of information that can quickly become indecipherable, especially when you are debugging but are unsure where an error is occuring. The tracedepth setting controls how deep into the subprograms the trace will go. For example, if you set tracedepth to 1 then none of the inside of any subprograms will be shown, you will only see the top level. The subprograms will still run, but all you will see is their output if there is any, you won’t see what is happening within the subprograms. If the subprogram is within a top-level subprogram you won’t see it at all. If tracedepth 1 is not specific enough, you can then increase this to tracedepth 2, etc.
To set the tracedepth:
set tracedepth #
When you turn trace off, the tracedepth is reset. This means if you turn trace on again later you will need to reset your tracedepth to your chosen value.
This setting controls the default storage type for new variables (e.g. those created with generate). You can choose from byte, int, long, float, double, and str#. To set the type you will need to specify one of those types just listed in the command. For a str default you will also need to give the number of characters (by byte size) for the string, which will be a number between 1 and 2,045. Put this number where the # is shown in the above list. To change the default type, use the following command and replace type_name with one of the types from the list in bold:
set type type_name
These are the most commonly used settings. For a full list of Stata settings check out the help file with the following command:
help set