The profile and sysprofile Do-Files – Automating Your Stata Start-Up

Stata allows you to create a special “profile” do-file that it will run every time you start the program. This do-file can contain any Stata commands that you always want to run when Stata first opens. For example, I have put in commands to open a log file and save it in a specific location whenever I open Stata. This is useful because it means everything I do in Stata is always logged, and if I am trying to re-create something I have done in a previous session I can just look everything up in the log file. I also have a command that sets the current working directory to a specific folder on my computer, rather than the default of my documents folder.


There are two different types of “profile” do-files – the “profile.do” or the “sysprofile.do”. Commonly the “profile.do” is placed in your home directory (e.g. C:/Users/Laura), and the “sysprofile.do” is placed in the Stata folder (e.g. C:/Program Files/Stata17). However, you can place both these files in any of the following places:

  • Your home directory – e.g. C:/Users/Laura

  • The Stata installation folder – e.g. C:/Program Files/Stata17

  • The current working directory

  • Along your user path

  • Along the ado-path


The profile.do

This file is where you put all your own personal settings. For example setting up a personal log, or changing the default working directory to a particular folder. Any and all commands that you want Stata to run at the start of every session should go here. Below is an image of my personal “profile.do” as an example:


The sysprofile.do

This file is for system administrators who run a Stata network or site licence. This is where administrators will put any commands that they want to run every time Stata is opened by anyone with access to the network or site licence. For example, administrators may want to change the path of some of Stata’s system directories. You might want the personal system directory be shared across the network so that everyone is working off the same user-written commands to keep version consistency.


 

It is important to note that Stata will always run the “sysprofile.do” first, before running an individual’s “profile.do”. If you are making changes in your “sysprofile.do” like setting a particular scheme or working directory to make it uniform, these will be overridden if the individual’s “profile.do” contains another version of the same command. For example, if you set the working directory to be on a server in the “sysprofile.do” but in the individual’s “profile.do” they also set their working directory to be in their documents folder, then the working directory will be the documents folder not the server. To avoid this, it is important to make sure the individuals using your network know what settings they can or cannot change in their “profile.do”.

512 views0 comments

Recent Posts

See All