Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Selecting observations


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Selecting observations
Date   Wed, 2 Apr 2014 13:38:17 +0100

You would probably benefit from setting up your dataset as panel data:

tsset id year

Then

local has has_health_insuranceA

drop if `has'  == 0 & year==4 & L1.`has' == 1 & L2.`has' == 1 & L3.`has'

or

drop if !`has' & year==4 & L1.`has' &  L2.`has' & L3.`has'

Nick
[email protected]


On 2 April 2014 13:31, Jacob-Jan Koopmans
<[email protected]> wrote:
> Dear Statalist,
>
> I have a problem with selecting observations.
>
> I would like to compare the health characteristics of people that drop
> out of insurance with that of people that remain insured.
>
> In my data-set I have 4 years and want to know whether people that
> drop out of insurance between year 3 and 4 but were insured in the
> first 3 years are more or less healthy compared to the individuals
> that remain insured in year 4. For this I would thus like to drop
> observations that were uninsured in year 1 to 3 and in year 4 I would
> like to keep the individuals that became uninsured.
>
> Dropping out the observations that were uninsured in the first 3 years
> is simple.
> Initially I started with simple drop commands
> drop if has_health_insuranceA==1 if year==1
> drop if has_health_insuranceA==1 if year==2
> drop if has_health_insuranceA==1 if year==3
>
> However, in year 4 I now want to select individuals which were insured
> in year 1, 2 and 3 but not anymore in year 4. And have no idea how to
> do this.
> Is there anyone who could help me with this?
>
> Kind regards,
> Jacob-Jan Koopmans
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index