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: RE: Dropping Countries


From   "Dimitriy V. Masterov" <[email protected]>
To   [email protected]
Subject   Re: st: RE: Dropping Countries
Date   Sat, 19 Mar 2011 17:05:20 -0400

You're missing a bracket before the closing parentheses:

bysort country(ses) : drop if missing(ses[1]) & missing(ses[_N])

DVM

On Sat, Mar 19, 2011 at 5:01 PM, ajjee <[email protected]> wrote:
> Hi
> It is an old thread but when I give the command suggested by Nick, I get the
> following error message.
>
> xtset country year
>
> . bysort   country(ses) : drop if missing(ses[1]) & missing(ses[_N)
> factor variables and time-series operators not allowed
> r(101);
>
> Thanks in advance
>
> ajjee
>
>
>
> Nick Cox wrote:
>>
>> bysort Countryname (ses) : drop if missing(ses[1]) & missing(ses[_N])
>>
>> If, after -sort-ing on -ses- within -CountryName-, it is true that the
>> first observation for a country contains a missing value and also that the
>> last observation does, then they all do.
>>
>> See if more detail is needed
>>
>> SJ-2-1  pr0004  . . . . . . . . . . Speaking Stata:  How to move step by:
>> step
>>         . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J.
>> Cox
>>         Q1/02   SJ 2(1):86--102                                  (no
>> commands)
>>         explains the use of the by varlist : construct to tackle
>>         a variety of problems with group structure, ranging from
>>         simple calculations for each of several groups to more
>>         advanced manipulations that use the built-in _n and _N
>>
>> Nick
>> [email protected]
>>
>> ajjee
>>
>> I have the data for near 180 countries for many variables over 26 years
>> but
>> I want to drop that countries which have no data for a specific variable.
>>
>> tab  countryname if ses==.
>>
>> CountryName |      Freq.     Percent        Cum.
>> -----------------------------+-----------------------------------
>>                      Algeria |         26        2.30        2.30
>>                       Angola |         26        2.30        4.59
>>                      Armenia |         26        2.30        6.89
>>                   Azerbaijan |         11        0.97        7.86
>>                      Belarus |         11        0.97        8.83
>>                        Benin |         26        2.30       11.13
>>                      Bermuda |         26        2.30       13.43
>>       Bosnia and Herzegovina |         12        1.06       14.49
>>                 Burkina Faso |         26        2.30       16.78
>>                     Cameroon |         26        2.30       19.08
>>             Congo, Dem. Rep. |         26        2.30       21.38
>>                  Congo, Rep. |         26        2.30       23.67
>>                Cote d'Ivoire |         26        2.30       25.97
>>                     Dominica |         26        2.30       28.27
>>            Equatorial Guinea |         26        2.30       30.57
>>
>>
>> Now I want to drop only countries where ses is missing for all years. Is
>> there any command to do so?
>>
>>
>> *
>> *   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/
>>
>
>
> --
> View this message in context: http://statalist.1588530.n2.nabble.com/Dropping-Countries-tp5769871p6188251.html
> Sent from the Statalist mailing list archive at Nabble.com.
> *
> *   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index