--- bumbuminc <[email protected]> wrote:
> I want to drop some Observations in Stata, who are out of a certain
> range.
> For example: I have 2 variables, the first one is an identnumber and
> the second one are the earnings.
> Now I want Stata to drop all the Observation who are under a minimum
> earning and all who are over a maximum earning and save this under a
> new variable.
You can either drop the observations (rows) that fall outside your
range, or you can create a variable (column) which identifies which
observations meet your criterium, but it doesn't make sense to do both
as in that case the variable identifying which observations are to be
used will be all ones. The latter option is safer as it keeps your data
intact, but it can be inconvenient in large samples and because you
will have to remember to add -if variablename==1- to all commands
afterwards. How to do this is best seen by showing an example. See the
example below:
*----------- begin example -----------
// create a variable
sysuse auto, clear
gen touse = mpg >= 20 & mpg <= 30
reg rep78 mpg if touse
// drop cases
sysuse auto, clear
drop if mpg < 20 | mpg > 30
reg rep78 mpg
*------------ end example ------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )
Hope this helps,
Maarten
-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands
visiting address:
Buitenveldertselaan 3 (Metropolitan), room N515
+31 20 5986715
http://home.fsw.vu.nl/m.buis/
-----------------------------------------
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/