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: Pick the first record with a value
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Pick the first record with a value
Date
Wed, 5 Feb 2014 14:06:51 +0000
-nparasit- looks like a string variable if values include "NEG".
gen Nparasit = real(nparasit)
gen missNparasit = missing(Nparasit)
bysort missNparasit numserial (date) : gen first = Nparasit[1]
Nick
[email protected]
On 5 February 2014 14:01, Keniajin Wambui <[email protected]> wrote:
> Hi Lucas;
> Thanks for that.
> I want to pick the first nparasit with a value sorting by date and numserial.
>
> On Wed, Feb 5, 2014 at 4:49 PM, Lucas Ferreira Mation
> <[email protected]> wrote:
>> I did not understand what you want exactly.
>> But as long as ndate_added is a numeric variable (formatted as a date)
>> and not a string variable it should be possible to do sorting or egen.
>>
>> For example:
>>
>> egen I=min(ndate_added), by(numserial)
>>
>> picks the first date of each group of numserial observations.
>>
>> On Wed, Feb 5, 2014 at 11:40 AM, Keniajin Wambui <[email protected]> wrote:
>>> Dear All;
>>> nparasit numserial ndate_added
>>> 42231 05-Jun-00
>>> 7992 42231 03-Jun-00
>>> 42242 04-Jun-00
>>> 144000 42242 05-Jun-00
>>> 712800 42242 04-Jun-00
>>> NEG 42242 08-Jun-00
>>> 371200 42242 06-Jun-00
>>> 10138 42242 07-Jun-00
>>> 110224 21-Dec-11
>>> 0 110224 12-Dec-11
>>>
>>> I am using Stata 12 on Windows 7 .I have a data set with duplicated
>>> numserials. I want to pick the first nparasit with a value acording to
>>> date added (ndate_added). I have tried using sorting but without
>>> success . How can I go about it
>>>
>>> --
>>> Mega Six Solutions
>>> Web Designer and Research Consultant
>>> *
>>> * 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/
>
>
>
> --
> Mega Six Solutions
> Web Designer and Research Consultant
> *
> * 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/