Hello,
I am currently facing three questions regarding the preserve and restore commands. I would be thankful for any clarifications on this.
(1) My first question is regarding example 1 in the STATA manual preserve.pdf . What exactly is the need for preserve in this example? If the user does not need the data back for further analysis, once she has the results, when she closes her dataset, the dataset will return to its original form unless she decides to save the new data.
(2) On page (1), under options, the manual states "preserve instructs restore to restore the data now, but not to cancel the restoration of the data again at program conclusion. If preserve is not specified, the scheduled restoration at program conclusion is canceled." What does this sentence imply? For every command, would we always not use the preserve command first and then the restore command.
(3) For my code, I am starting by cleaning the data. After I clean the data, I need to start doing different analysis that require the same clean data. I do not want to clean the data every time I work with different research questions, so I am using the preserve and restore commands in STATA. I am assuming the command would go something like:
************************************************** ***************************************
(clean the data)
*preserve the clean data
preserve
(research question 1 analysis)
*saving new research data from research question 1 analysis as a different file
save
*now I need to restore the clean data for my second research question
restore
*preserve again as I need to keep my original clean data
preserve
(research question 2 analysis)
*saving new research data from research question 2 analysis as a different file
save
*now restore the clean data
restore
************************************************** **********************************************
Once I close my dataset after my final command "restore", I wanted to confirm that the data would go back to its original form (the one that was there before I cleaned the data).
Thank you for your time!
I am currently facing three questions regarding the preserve and restore commands. I would be thankful for any clarifications on this.
(1) My first question is regarding example 1 in the STATA manual preserve.pdf . What exactly is the need for preserve in this example? If the user does not need the data back for further analysis, once she has the results, when she closes her dataset, the dataset will return to its original form unless she decides to save the new data.
(2) On page (1), under options, the manual states "preserve instructs restore to restore the data now, but not to cancel the restoration of the data again at program conclusion. If preserve is not specified, the scheduled restoration at program conclusion is canceled." What does this sentence imply? For every command, would we always not use the preserve command first and then the restore command.
(3) For my code, I am starting by cleaning the data. After I clean the data, I need to start doing different analysis that require the same clean data. I do not want to clean the data every time I work with different research questions, so I am using the preserve and restore commands in STATA. I am assuming the command would go something like:
************************************************** ***************************************
(clean the data)
*preserve the clean data
preserve
(research question 1 analysis)
*saving new research data from research question 1 analysis as a different file
save
*now I need to restore the clean data for my second research question
restore
*preserve again as I need to keep my original clean data
preserve
(research question 2 analysis)
*saving new research data from research question 2 analysis as a different file
save
*now restore the clean data
restore
************************************************** **********************************************
Once I close my dataset after my final command "restore", I wanted to confirm that the data would go back to its original form (the one that was there before I cleaned the data).
Thank you for your time!
Comment