Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: cancel a selection and continue working with all the variables or category of a variable


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: cancel a selection and continue working with all the variables or category of a variable
Date   Wed, 3 Sep 2008 14:00:53 +0100 (BST)

--- carmen gamarra <[email protected]> wrote:
> I know how I would like to cancel a selection and continue working
> with all the variables or category of a variable?
> 
> Example:                     keep if  yearfile=="1996"
> 
> and then (cancel select)   cancel the selection and working with all
> the categories: 

-keep if expression- means you throw away everything for which
expression is false. Once you throw it away, it is gone forever (unless
you follow strategy 1 below).

There are two strategies you can follow:
1)
preserve
keep if yearfile == "1996"
reg y x /// regression on selection 
restore
reg y x /// regression on complete file

2)
gen byte touse96 = yearfile == "1996"
reg y x if touse96 /// regression on selection
reg y x            /// regression on complete file

see -help preserve- for more on strategy 1, and -help if- for more on
strategy 2. In most cases I would prefer strategy 2.

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 Z434

+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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index