4 Some Stata basics

4.1 Folders

I assume that you have a folder structure something like

Project Folder
├── raw_data
├── scripts
│   ├── cleanmydata.do
│   └── modelmydata.do
├── documentation
│   ├── PDFs
│   └── Word_docs
└──graphs

(though you probably don’t have scripts named cleanmydata.do and modelmydata.do, those are just examples). Of course, other folder set-ups are possible, so be aware of your own as you follow the rest of this guide. The path to my main project folder,for example, is

c:\users\jt\Documents\Projects\StataWrangling

4.2 Exercise

If you do not have a folder for your project (including for this training series project!), create one now with subfolders as above. You do not need to create the two do files in the scripts folder. You can do this in Stata. First type

pwd

and then hit enter. Check the result and make sure that it shows the directory where you want to store your projects. To create the structure, you will find it easier right now using your computer’s graphical user interface, but in case you want to do it in Stata, type the following Stata commands on the console (the command window), following each by return (replace ProjectName with a suitable name for your project)

mkdir ProjectName
cd ProjectName
mkdir raw_data
mkdir scripts
mkdir documentation
mkdir graphs
cd documentation
mkdir PDFs
mkdir Word_docs
cd ..
pwd

Check that you end up back in your new project folder.

4.3 Exercise

Using your operating systems file explorer, check the folder structure you just created for your project. If it isn’t what you expect, correct it.

4.4 Common File types

You will commonly encounter three types of file specific to Stata

  • The .dta file which is Stata’s proprietary data format;
  • The .do file which is Stata’s scripting file type;
  • The .log file which is the file type recording session logs.