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.)
« Updating tip | Command log files »
Thursday
Mar032011

Setting return messages on

Lately I have been working with some very large datasets and have been interested in how long Stata commands take to complete. The set rmsg on command has been useful for showing how long each command takes to execute, as well as the time it completed. To turn on return messages, you can type

. set rmsg on
To illustrate the effect of this command, let's use the auto dataset and the run a logistic regression.

. sysuse auto (1978 Automobile Data) r; t=0.00 10:52:02 . logit foreign gear_ratio displacement turn length weight Iteration 0: log likelihood = -45.03321 Iteration 1: log likelihood = -21.846131 Iteration 2: log likelihood = -16.826028 Iteration 3: log likelihood = -15.938989 Iteration 4: log likelihood = -15.883186 Iteration 5: log likelihood = -15.88236 Iteration 6: log likelihood = -15.88236 Logistic regression Number of obs = 74 LR chi2(5) = 58.30 Prob > chi2 = 0.0000 Log likelihood = -15.88236 Pseudo R2 = 0.6473 ------------------------------------------------------------------------------ foreign | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- gear_ratio | 3.536476 1.799346 1.97 0.049 .0098232 7.063128 displacement | -.0371318 .033608 -1.10 0.269 -.1030023 .0287388 turn | -.5515612 .242733 -2.27 0.023 -1.027309 -.0758133 length | .1025261 .0834969 1.23 0.219 -.0611249 .2661771 weight | -.0001706 .0027558 -0.06 0.951 -.005572 .0052307 _cons | -3.973186 10.60993 -0.37 0.708 -24.76827 16.8219 ------------------------------------------------------------------------------ r; t=0.48 10:52:33

Each command ends with a return message that begins with r; and then shows the amount of time it took to execute the command and when the command completed. The sysuse command took almost no time at all (less than a tenth of a second). The logit command took .48 seconds and completed at 10:52am. This can be useful for seeing how long a particular command takes to complete. This setting will also show how long a do-file takes to complete (and the time it completed).

If you want to make this setting permanent, you can type set rmsg on, permanently and Stata will remember this setting for future Stata sessions.

For more information, you can see help rmsg.

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 http://www.MichaelNormanMitchell.com/storage/stowdata 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 http://www.michaelnormanmitchell.com/ .

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.