Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

RE: st: RE: Filtering data


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: Filtering data
Date   Wed, 30 Jun 2010 00:09:41 +0200

<>

For the -by- case, -egen- is more appropriate:


*************
sysuse auto, clear
bys rep78: egen pctwgt90=pctile(weight), p(90)
bys rep78: egen pctwgt10=pctile(weight), p(10)
drop if (weight> pctwgt90 & !mi(weight)) | weight < pctwgt10
*************

So "rep78" takes the place of your route_code, and "weight" is your
travel_time.


HTH
Martin


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Maximiliano
Manuel Silva Correa
Sent: Mittwoch, 30. Juni 2010 00:03
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: RE: Filtering data

Thank you Martin.

My data is something like

date    route_code   start_time   end_time    travel_time

Id like to do something like

by route_code: drop if travel_time  > p90 | travel_time < p10

How is the sintaxis for that?

Thank you in advance,

Max

2010/6/29 Martin Weiss <martin.weiss1@gmx.de>:
>
> <>
>
> We cannot possibly know the true structure of your data, but to show the
> mechanics of -drop-ping:
>
> *************
> sysuse auto, clear
> summarize weight, d
> drop if weight< `r(p10)' | (weight > `r(p90)' & !mi(weight))
> *************
>
>
> Most of the time, you do not need to -drop- outright, just condition via
the
> -if- qualifier.
>
>
> HTH
> Martin
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Maximiliano
> Manuel Silva Correa
> Sent: Dienstag, 29. Juni 2010 23:42
> To: statalist@hsphsun2.harvard.edu
> Subject: st: Filtering data
>
> Dear Stata community,
>
> Im currently analizing travel times for serveral urban bus trips in
> the city of Santiago, Chile. I'm using lots of data coming from GPS
> sources.
>
> Pretty newbie to Stata,  Im stuck trying to filter data by bus trip
> route codes; Id like to drop all observations wich have travel times
> under percentile 10 and over percentile 90 for all observations
> sharing a certain route code... this filter for all route codes.
>
> How could I do this?
>
> Thank you in advance.
>
> Max
> *
> *   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/
>

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