*! version 1.0.2 22may2020

stop

stop -- Stata command to interrupt dofiles intelligently (closes logfiles and optionally sends a message to your smartphone)

Syntax

stop
[, sts(string) message(string) logfile(string)} saveoptions]

Main
sts(string) sendtoslack url, name or "default"

message(string) message you want to display and optionally send to slack

logfile(string) logfile to close (default: any open logfiles)

save saves specified options as default (so you can omit them)

Description

stop stops dofiles, closes any running logfiles and optionally sends a message to your smartphone (see sendtoslack).
The main inspiration for this command is frustration - often you want to run a dofile up to a certain point and evaluate the results. In simple cases, an "exit" or "error 1" works just fine.
But when you are running the same dofile in multiple instances (potentially on different machines), this gets tricky, because any log files you have open will now
throw an error if you try to use them elsewhere.
Moreover, if your dofiles take ages to run, it would be great if you were informed when they finish.

This command saves you the hassle of coding all those things manually (every time). stop will close any logfiles that are open (or just some of them, see below). If desired,
it will then inform you that you reached the stopping point by sending a message to your cellphone through Slack. Once that's done, it will
stop the dofile by throwing an error 1, which is equivalent to pressing the red break button in the command window.

Finally, to cater to my own laziness, stop has a save option, which places any options you specified in the profile.do file.
The command will then use these options the next time you call for a stop, without requiring you to add the options. It's quite cool, even though I say so myself.

Options

sts(string) If you specify a valid sendtoslack url or name in sts, stop will send a message to the specified Slack room to inform you
the dofile stopped. If you want to send to the default you saved in sendtoslack, specify sts(default). See sendtoslack for more information about
saving sendtoslack urls as names or defaults.

message(string) The message option is mainly interesting if you are sending messages to a Slack room, as it allows you to customise said message. This is particularly
useful when stopping multiple dofiles, as you can then use the message to distinguish which one has finished.

logfile(string) There might be moments when you don't want to close all logfiles. The logfile option allows you to specify
the name of the logfile to be stopped, allowing any other to continue.

save It is tiresome to specify these options all the time. The save option stores the options you provided in your profile.do
file. A simple stop without any options would then send the correct message to the right Slack room (and stop the right logfile). See the examples for an illustration.

Examples

Stop dofile, close all logs.

. log using temp, replace

. stop

Stop dofile, close all logs and send a message to Slack

. log using temp, replace

. stop, sts(https://hooks.slack.com/services/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)

Stop dofile, close specific log and send a custom message

. log using temp, replace name(keepRunning)

. log using temp2, replace name(closeThisOne)

. stop, message(A custom message) logfile(closeThisOne) sts(https://hooks.slack.com/services/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)

. log close keepRunning

Save sts url and message (will not stop program or close logfiles)

. log using temp, replace

. stop, save m(This is a saved custom message!) sts(https://hooks.slack.com/services/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)

. log close _all

Use saved url and message

. log using temp, replace

. stop

Do not use saved url and message (just stop)

. log using temp, replace

. stop, sts(overwrite) m(overwrite)

Author

Jesse Wursten
Faculty of Economics and Business
KU Leuven
jesse.wursten@kuleuven.be

Other commands by the same author

sendtoslack Stata Module to send notifications from Stata to your smartphone through Slack

xtqptest Bias-corrected LM-based test for panel serial correlation

xthrtest Heteroskedasticity-robust HR-test for first order panel serial correlation

xtistest Portmanteau test for panel serial correlation

xtcdf CD-test for cross-sectional dependence

timeit Easy to use single line version of timer on/off, supports incremental timing

pwcorrf Faster version of pwcorr, with builtin reshape option