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   "Martin Weiss" <[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 15:17:46 +0200

I observe great unanimity with regard to the answer. But it is all a
duplication of effort as everything has been said on this point:
http://www.stata.com/statalist/archive/2008-08/msg01305.html

Martin

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Maarten buis
Sent: Wednesday, September 03, 2008 3:01 PM
To: [email protected]
Subject: Re: st: cancel a selection and continue working with all the
variables or category of a variable

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


*
*   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