Saving a Dataset in Stata Format

Saving a Dataset in Stata Format

Updated July 2018 Saving a Dataset in Stata Format This set of notes describes how to save a dataset within the computer program Stata. It assumes that you have set Stata up on your computer (see the “Getting Started with Stata” handout), and that you have read in the set of data that you want to analyze (see the “Reading in Stata Format (.dta) Data Files” handout). In Stata, most tasks can be performed either by issuing commands within the “Stata command” window, or by using the menus. These notes illustrate both approaches, using the data file “GSS2016.DTA” (this data file is posted here: https://canvas.harvard.edu/courses/53958). If you make modifications to an original dataset (say by recoding variables, or creating new ones), it is best practice to save the modified dataset as a new data file, instead of overwriting the original file. That way if there turn out to be errors in the modified file, you can always start afresh with the original dataset. To save a dataset as a new data file you type in the Stata Command box save ”filepath & filename” On a PC: If one wanted to save a modified GSS2016.DTA dataset as a new data file (GSS2016_v2.dta) on hard disk C:, in the folder DATA, one would type save "C:\DATA\GSS2016_v2.dta" On a Mac: If one wanted to save a modified GSS2016.DTA dataset as a new data file (GSS2016_v2.dta) in user1’s folder on the hard drive, in the folder data, one would type save "/Users/user1/data/GSS2016_v2.dta" To replace an existing data set with a newer version, add the “replace” option after the file name in the “save” command, like this: save "C:\DATA\GSS2016_v2.dta”, replace This can be a good idea if you are making many changes to a data set; save/replace the data file periodically, while always retaining a copy of the original dataset you began with. Alternately, use the menu: click on File, then on Save As. Navigate to the folder where you want to save your data set and enter the file name. Then click Save. (If doing this would replace an existing dataset, you will see a pop-up window that asks you to confirm that this is what you indeed want to do.) .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    1 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us