Is there a convenient way to temporarily use a subset of the data (i.e. just selecting or deselecting a number of cases without really dropping them form your data file)? I know you can use 'if', but if you have a lot of commands repeating 'if' every line is a bit cumbersome. Another option is to use 'keep' or 'drop', but then part of the cases is really deleted ... if you then want to return to the full data set (or anothter subset), you have to reload the original data (and possibly redo a lot of data manipulations) ...
Code:
* First option sysuse auto * Suppose I (temporarily) want to do some analyses on cars with price > 4000, * I can add 'if price>4000' to every command (ok for a couple of lines, * but not so convenient if you have a lot of commands)... sum if price>4000 kdensity mpg if price>4000 tab rep78 foreign if price>4000 reg mpg weight foreign if price>4000 * ... and if I now want to return to all observations, I just do whatever I want without 'if' * Second option sysuse auto * Use 'keep if price>4000', but if I then want to return to all observations, * I have to reload the original file (and possible redo a lot of preliminary data manipulations) keep if price>4000 sum kdensity mpg tab rep78 foreign reg mpg weight foreign * Third option ???
Mike
0 Response to Temporarily use subset of data
Post a Comment