Stata Programs

On this page are stata programs I have created and published and are now available to all stata users. These are stata programs I have written and use regularly in my research. Typically these are programs I have created as a means to boost productivity by automating a particular task.

To download the .zip folder containing the .ado file and .sthlp file click on the program name. To use the program, extract the contents to the folder where stata stores additional .ado programs. This is typically 'C:\ado\personal'. Alternatively, if a link is provided to the EconPapers page then that program has been submitted to the ssc archive and can be installed as per any other user written command, by typing 'ssc install' followed by the program name in the stata terminal.

Editing and compiling latex files

texmerge is a stata module that merges .tex files in a specified order and then compiles the merged .tex file to .pdf using pdflatex. Users can input a selection of files to be merged or can merge all .tex files stored in the same folder. Text can also be added to the beginning of the new merged .tex file and the end of the file. This allows users to include preamble arguments such as '\documentclass[]{}' and '\begin{document}' to the .tex file and to close the file using '\end{document}'.

Suggested use: To merge many tables created using esttab or a similar program into a single .tex document and compile this document to .pdf automatically.

Dependencies: tknz, appendfile, texcompiler

texcompiler is a stata module that allows users to add text to the beginning and the end of a .tex file and then compiles the document to .pdf using pdflatex. texcompiler creates a new duplicate .tex file with the inputted modifications and compiles this new .tex file. Users can apply texcompiler to a single file, a selection of files, or all .tex files located in a specified folder.

Suggested use: To compile a series of tables stored in separate .tex documents created using a stata program such as esttab

Dependencies: tknz, appendfile

Email Suite

Currently Email Suite programs are for windows users only (sorry!)

pscred uses windows powershell to capture and store users credentials. The program will open a windows powershell terminal and a pop-up window will request users input their username and password. The username will be stored as a plain .txt file in a specified location while the password will be stored as a secure string.

It is recommended that users do not store their credentials on their local system. pscred is designed to store credentials only temporarily for use in other programs in the email suite. Typically these programs delete users credentials upon completion (successful or otherwise).

Suggested use: pscred was created only as a useful tool for other programs in the email suite

Dependencies: Windows Powershell be installed on the users system

winmail is a stata module that uses windows powershell to send an email via SMTP (Simple Mail Transfer Protocol). Winmail creates a .ps1 script which is then run using windows powershell. Emails are sent via the Send-MailMessage cmdlet.  The program is flexible and uses pscred to capture users credentials, deleting them upon completion.

Users can send email from any email address that uses SMTP. Some mail providers will require access settings be modified (such as gmail). Emails can be formatted using html and attachments can be included.

Suggested use: Send an email on the completion of a program, attaching the .tex file outputted by the program being run.

Dependencies: pscred, tknz, and Windows Powershell be installed on the users system

eofmail is a stata module that sends an email on the completion of a .do file. An email is sent using winmail informing users if the program ran successfully or with error. In the event that the program exited with error the email message will contain the error message and if desired, the .log file. 

A successful email message will contain the text body: "You nailed it! Your program ran successfully without error." An unsuccessful email will contain: "Unfortunately things didn't go as planned. But that's OK. It will be better next time. Here is the error message:" followed by the error message.

The stata help file for the program provides some useful guidance on how to use eofmail when tasks are separated into a series of sequential .do files or into one nested .do file.

Suggested use: This program was created because I found myself performing very time intensive operations with no idea on when they would end and whether they would run successfully or with error. There is nothing more frustrating than leaving a program for several hours thinking it is running when it stumbled upon an error in the first 15 minutes! This program is ideal when performing very long tasks to ensure you are not checking your computer incessantly.

Dependencies: pscred, tknz, winmail and Windows Powershell be installed on the users system

bulkmailer is a stata module that sends many similarly formatted emails to different email addresses. This program allows users to send emails to many users replacing keywords or lines of text for each user. The information to be substituted for each email recipient must be stored in a .dta file, with each column representing various inputs to the program.

Suggested use: bulkmailer was created so that I could send individual emails to an entire class with their individual grade inputted into the email body. This program achieves this task easily and allows for much more flexible emails to be sent. For instance, users could provide personalized comments to each student.

Dependencies: pscred, tknz, winmail and Windows Powershell be installed on the users system

Editing .do files

comdelete deletes comments from a .do file. It distinguishes between single line comments and block comments. It creates a duplicate .do file with all specified comments removed. Multiple files can be processed at the same time.

Suggested use: Some secure data centers allow for the extraction of syntax files with comments removed. This program was created so that comments can be easily and quickly removed from .do files from inside stata. 

Dependencies: none