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: How do I drop fist and last observations please?


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: How do I drop fist and last observations please?
Date   Mon, 18 Jul 2011 15:03:50 -0500

drop in 1
drop in L

If the datasets are all small, then

drop if _n == 1 | _n == _N

should be about as fast. For a big dataset, that is probably a bad
idea, as Stata will test to see if every observation satisfies the
-if-.

Nick

On Mon, Jul 18, 2011 at 1:37 PM, Lucie Vlach
<[email protected]> wrote:

> I need to drop my first and last observation from a data set in a do file.
> Not all datasets will have the same number of observations. Is there a good ‘drop’ command that will do this for me, regardless how long my dataset is? It will always be the first and last observation.
>
> Here is the example of my data:
>
> Record_Type Sub_Prefix Current_Yr Source Sequence_Number Check_Digit Transaction_Type Segment_Type Segment_Sequence Action_Code Unused Claim_Type Service_Provider_ULI Skill_Code Service_Recipient_ULI
> 2 UCM 00 00 80
> 3 UCM 11 00 00546733 4 CIP1 CIB1 0001C   RGLR 3535446208 PSYC 352543330
> 3 UCM 11 00 0037920 6 CIP1 CIB1 0001A   RGLR 2296454208 GP 445454551
> 4 UCM 00 00 8000143 0 0000 144
>
> Here I want to drop: “2 UCM 00 00 80” and “4 UCM 00 00 8000143 0 0000 144”
>

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index