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 first and last observations please?
From
Lucie Vlach <[email protected]>
To
"[email protected]" <[email protected]>
Subject
RE: st: How do I drop first and last observations please?
Date
Mon, 18 Jul 2011 14:40:55 -0600
Thank you Nick!
drop in 1 and drop in L worked great, and for now, the datasets are small. They may get bigger in the future.
Lucie
________________________________________
From: [email protected] [[email protected]] On Behalf Of Nick Cox [[email protected]]
Sent: July 18, 2011 2:03 PM
To: [email protected]
Subject: Re: st: How do I drop fist and last observations please?
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/
This message and any attached documents are only for the use of the intended recipient(s), are confidential and may contain privileged information. Any unauthorized review, use, retransmission, or other disclosure is strictly prohibited. If you have received this message in error, please notify the sender immediately, and then delete the original message. Thank you.
*
* 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/