Creating a Log File


Every time you start a new Stata session make it a habit to:

  1. Change the working directory, and
  2. Create a log file. 

The first step allows you to link the Stata session to a folder on your computer’s hard drive and the second step creates a permanent record of your results.

For example, let’s assume you have a folder labeled data on your C:\ drive where you keep all the project files. It doesn’t have to be a C:\ drive it could be a folder on your USB drive or Dropbox. Go ahead and create the data folder. Next, from the menu bar select File > Change working directory on the main menu bar. From the pop-up window browse to the data folder and click OK. The Stata session is now linked to the data folder.

When you create a log file using a Stata command in the next step you don’t have to specify the complete path. It saves time. You will notice that the folder path in the lower left window has changed in my case to D:\data. When you use point-and-click menu, Stata automatically generates a command in the Results window: cd “D:\data”


Now, let’s create a log file. Stata allows you to create a log file with .log (a text file) or .smcl (Stata Markup and Control Language) extension. I recommend creating the log files with .log extension, which can be opened using a notepad. SMCL log files can only be opened from within Stata.

You can create a log file using the menu bar File > Log > Begin. From the pop-up window browse for the data folder, name the log file, make sure to save it as .log (the default is smcl) and click OK.

Log File


The Results window will show 1) the command (syntax) Stata used to create the log file, 2) time stamp, and 3) will indicate if the log is currently on. You can temporarily turn off the log by typing

log off

in the command window. To exit the log just type

log close

Log files are saved automatically. All Stata commands are lowercase.



Let’s say you want to use an existing log file that you created in an earlier Stata session.  Once you start a new Stata session and change the working directory to link the Stata session to the folder go through the same step as before File > Log > Begin. From the pop-up window browse for the data folder, select the existing log file, make sure to select .log (the default is smcl) extension from the drop-down menu and click Save. A small window will appear. Select Append to existing file and click OK

Append the Log File

Append Syntax

Alternately, you can simply type

log using project.log, append

You don’t have to type the complete path (i.e., D:\data\…) as long as you have linked the Stata session to the folder where the project.log file resides.

You are now ready to open and analyze a Stata dataset.


0 thoughts on “Creating a Log File”

  1. chapel hill apartments

    Alabama football sec & Video
    Alabama football sec Alabama football sec 2007 Alabama Football If you are looking for our Current Alabama Football page, check out 2010 Alabama Crimson Tide football. Alabama football took a nice step forward with its 30-24 win over Colorado in the Independence Bowl. It was an important win to ensure they ended the season on an up note and with a winning (7-6) record. Alabama showed great potential early this season. We think they will be stronger under Nick Saban next year and probably challenge for the SEC-West crown. And the Tide took a bigger step forward with their 2007-2008 …
    The post Alabama football sec & Video appeared first on Earnings .

    Tulsa Business


Leave a Reply

Your email address will not be published. Required fields are marked *