Stata Tidbits

These tidbits contain bits and pieces of information I hope you find helpful to use Stata more effectively. You can receive notifications of new tidbits as they are added (via email) by clicking on the subscribe box at the left. (Every email has an unsubscribe link, making it a snap to unsubscribe.)
« Setting return messages on | Creating multiple log files »

Command log files

Did you know that you can create a log file that stores just your Stata commands? These are called command log files and can be created using the cmdlog command. These kinds of log files can be useful if you want to save the commands, but not the output, from your Stata session. This can be useful, for example, if you are trying out some commands that you will later edit and combine into a do-file.

You can begin a command log with the cmdlog command, for example...

. cmdlog using mycommands
opens up a log file named mycommands.txt. Note that the extension for command files is .txt, emphasizing that they are text files.

Now, every command that you type (and just the commands) will be saved in the file mycommands.txt.

When you want to close the file, you can type the command.

. cmdlog close

The log then contains all of the commands that you typed after opening the command log. Here is an example.

. type mycommands.txt sysuse auto describe summarize

If you exit Stata before closing the command log file, Stata will close the file for you. You can have a command log and a regular log open at the same time. For more information, see help log.

You can download the example data files from this tidbit (as well as all of the other tidbits) as shown below. These will download all of the example data files into the current folder on your computer. (If you have done this before, then you may need to specify net get stowdata, replace to overwrite the existing files.

net from net get stowdata
If you have thoughts on this Stata Tidbit of the Week, you can post a comment. You can also send me an email at MichaelNormanMitchell and then the at sign and gmail dot com. If you are receiving this tidbit via email, you can find the web version at .

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.
Editor Permission Required
You must have editing permission for this entry in order to post comments.