Opening and Creating .dta Data Files


Creating a Dataset in Stata

Creating a dataset from scratch in Stata is easy. This page describes the easiest method for beginners. 

Entering the data

Start by clicking on the "Data Editor (Edit)" button, which looks like this: 

This will bring up a window that looks like this: 

From here you can enter your data much like you would in Excel. Here's an example using data I made up: 

Let's assume the first column is whether someone voted for Obama or Romney, the second gender, the third race, the fourth education, and the fifth age. 

Renaming the variables

To rename the variables (which are automatically named var1, var2, etc.), click on one of the cells in the column you want to rename. In the above example, the 11th row of the var1 column is selected. We can now go over to the "Properties" box in the lower right hand corner, highlight the name "var1" and replace it with something new. Let's call it "votechoice." You can rename the same variables using the same method. Alternately, you can also now double click on the column name in the dataset ("var2," etc.) and just start typing. Hit enter to accept the new name.

You can also rename the variables using the "rename" command. If you were to close the Data Editor window and type "rename var1 votechoice," it would rename "var1" as "votechoice." In fact, this is what Stata is actually doing if you use the first method (it just runs it for you, rather than you having to type it in yourself). 

You can also now save the dataset as a .dta file if you want to have it available for future analysis in Stata.




Continue to Transforming Variables >>


Return to Saving Files


Questions, comments, concerns?
Send an email to the Empirical Reasoning Lab
Or drop in during the Lab's open hours