6. Saving data

Obviously when you create or are given a data set for your work, you need to save this file somewhere sensible.  It’s really bad practice to use it from your ‘downloads’ folder, or your desktop (just for example … and yes, people actually do this … but not you!).


There are two key commands for saving and replacing a data file:

Table 3


So, once you’ve decided where you’re going to save your files (you would have already done this when defining your working folder, so we should be ok at this point), you can use the save command to save your file where you want it, e.g.,:

. save " E:\Stata_workshop\lifeexp_revised.dta"


You can add the replace command after a comma at the end of the save command if you already have a data set in the same location by the same name and you wish to replace it. 

. save "E:\Stata_workshop\lifeexp.dta", replace


If you do not wish to replace the file, you’ll need to save the data set under a new name, as per the first save example.


task  Task:   Save your data set

Save your data set to your working folder for this workshop (on your USB drive, where your working folder is), e.g.:

. save " E:\Stata_workshop\lifeexp.dta"