Home  /  Resources & Support  /  Introduction to Stata basics  /  Getting started

Hi and welcome to Stata. I am going to assume that you are new to Stata and just opened Stata for the first time. I'd like to show you a few basic commands to get you started. You should see a Command window at the bottom of the Stata interface. Let's begin by typing pwd in the Command window.

. pwd

The pwd command displays the path of the current working directory. You can change to a different working directory by typing cd in the Command window followed by the path of the new working directory.

. cd c:\temp
c:\temp

You can view a list of the files in this directory by typing dir if you are using Windows or ls if you are using a Mac, Linux, or Windows.

. ls

Next let's open a dataset named auto.dta that was included when you installed Stata.

. sysuse auto.dta
(1978 automobile data)

Note that the file extension .dta is unnecessary, but it doesn't hurt to include it.

You can verify that the dataset is open by looking at the Variables window at the top right of the Stata interface. You should see variable names like make and price in the Variables window.

You can also type describe in the Command window to see a list of the variable names and other information.

. describe

Contains data from C:\Stata\ado\base/a/auto.dta
 Observations:            74                  1978 automobile data
    Variables:            12                  13 Apr 2022 17:45
                                              (_dta has notes)

Variable Storage Display Value
name type format label Variable label
make str18 %-18s Make and model price int %8.0gc Price mpg int %8.0g Mileage (mpg) rep78 int %8.0g Repair record 1978 headroom float %6.1f Headroom (in.) trunk int %8.0g Trunk space (cu. ft.) weight int %8.0gc Weight (lbs.) length int %8.0g Length (in.) turn int %8.0g Turn circle (ft.) displacement int %8.0g Displacement (cu. in.) gear_ratio float %6.2f Gear ratio foreign byte %8.0g origin Car origin
Sorted by: foreign

We will discuss the details of describe in another lesson, but here we used it to verify that we opened the auto dataset successfully.

You can save a copy of the auto dataset to your local drive or cloud account by typing the save command followed by the filename.

. save myauto.dta
file myauto.dta saved

You will need to add the replace option if you wish to save the dataset again.

. save myauto.dta, replace
file myauto.dta saved

You can remove a dataset from Stata's memory by typing clear in the Command window.

. clear

You can open an existing dataset by typing use followed by the name of the dataset.

. use myauto.dta
(1978 automobile data)

You can also add clear as an option to use if you wish to open a new dataset while another dataset is open.

. use myauto.dta, clear
(1978 automobile data)

You can watch a demonstration of these commands by clicking on the link to the YouTube video below. You can read more about these commands by clicking on the links to the Stata manual entries below.