Nothing to restore error

人盡茶涼 提交于 2019-12-11 06:34:36

问题


I have a do-file that i use to clean-up a Stata dataset and generate descriptive statistics. The first command in this file is preserve, while the last one is restore.

The do-file is too long to attach on here but between these two commands, there are others such as generate, replace, tabulate and collapse.

The problem is that sometimes i get the following error message:

nothing to restore

Does anyone know what might be wrong?


回答1:


The problem presents itself when you are trying to run certain lines of code in your do file in chunks, as opposed to running the entire do file in one go.

To illustrate that this is indeed the case, consider the following toy example:

sysuse auto, clear

preserve

keep price mpg weight foreign

regress price mpg weight foreign

restore

If you select the first three lines from the above code snippet and press "Execute" in the do-file editor, Stata will successfully carry these out and then will automatically restore the dataset.

(To see this, just comment out preserve in the above example. In this case, the dataset upon completion of running the selected code will only contain the four variables specified.)

Now, if you try to run the rest of the code, Stata will complain:

. restore
nothing to restore
r(622);

The reason for this is because Stata has already restored the dataset.



来源:https://stackoverflow.com/questions/50881707/nothing-to-restore-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!