![]() ![]() This would replace the existing data set with a new one with one row per state, containing a variable indicating which state, a variable indicating the average BMI in that state, and a variable indicating the percent of the state which is female.Ĭollapse is a destructive command after running it the original data (and any unsaved changes) is lost. collapse (mean) bmi (percent) female, by(state) For example, if we have some sort of census data. The collapse command generates a summary data set by collapsing the existing data by a given variable and creating summary statistics. To see an example of it, consider the collapse command. preserve takes a snapshot of the data as it currently is, and restore switches back to it. The preserve and restore commands can be very useful for switching between files or making destructive modifications to an existing data set. You can also pass clear as an option to use/ sysuse/ webuse/ import to save one step. The clear command will remove the existing data and allow you to load a new data set. If you try and open a new data set when there are un-saved changes in the existing data, Stata will refuse. Passing the replace option allows Stata to overwrite an existing file. You can save a data set with the save command which works as. After you run the import, the command it generated is echoed and you can save it to run again. The Import dialog box has a live preview as you change settings which can be very useful.
0 Comments
Leave a Reply. |