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 on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Random sample panel data


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Random sample panel data
Date   Sun, 22 Apr 2012 18:17:16 +0100

As already pointed out by Prakash

select(_N)

is wrong.

select[_N]

is needed.

On Sun, Apr 22, 2012 at 6:00 PM, Caliph Omar Moumin
<sheikmoumin@yahoo.com> wrote:
> Dear Prakash thank of trying. i generated the variable, i used as in the example to follow.
>
> this is what did
>
> sort Nr
>
> . gen long order = _n
>
> . egen select = tag(Nr)
>
> . gen random = runiform()
>
> . sort select random
>
> . replace select = _n> (_N-10)
> (24091 real changes made)
>
> . bysort Nr (select): replace select = select(_N)
> unknown function select()
> r(133);
>
> after this i could´t continue because of the error
>
> Kind Regards,
> Moumin
>
> Email:  sheikmoumin@yahoo.com
>
>
>
> ----- Original Message -----
> From: Prakash Singh <prakashbhu@gmail.com>
> To: statalist@hsphsun2.harvard.edu
> Cc:
> Sent: Sunday, April 22, 2012 6:52 PM
> Subject: Re: st: Random sample panel data
>
> Dear Moumin, I am not sure whether this will help you or not but what
> looks to me is select is a generated variable.
>
> I am just putting this command for your understanding form the same
> place you have used the example of command
> bysort hhid (select): replace select = select[_N]
>
> egen select = tag(hhid)
>
>
> Prakash
>
> On Sun, Apr 22, 2012 at 7:17 PM, Caliph Omar Moumin
> <sheikmoumin@yahoo.com> wrote:
>> Thank you Nick i have seen this before. But does´t work for me.
>> 1.the first option takes only once per observation
>> 2. the second option: Stata does not execute the command
>> bysort hhid (select): replace select = select[_N].
>> in my data it is like this
>> bysort Nr (select): replace select = select(_N)and this error comes outunknown function select()
>> r(133);
>> I don't know what is the problem is? I would appreciate if someone could help me.
>> Kind Regards,
>> Caliph Moumin
>>
>> Email:  sheikmoumin@yahoo.com
>>
>>
>>
>> ----- Original Message -----
>> From: Nick Cox <njcoxstata@gmail.com>
>> To: statalist@hsphsun2.harvard.edu
>> Cc:
>> Sent: Saturday, April 21, 2012 12:48 AM
>> Subject: Re: st: Random sample panel data
>>
>> You can help yourself. The Statalist FAQ advises at
>>
>> http://www.stata.com/support/faqs/res/statalist.html#before
>>
>> "search can tell you about all built-in Stata commands, all ado-files
>> published in the Stata Technical Bulletin or the Stata Journal, and
>> all FAQs on the Stata website, www.stata.com."
>>
>> Here you are:
>>
>> FAQ     . . . . . . . . . . . . . . . . . . Sampling clusters, not individuals
>>         . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox and S. Merryman
>>         5/06    How can I sample clusters, not individuals?
>>                 http://www.stata.com/support/faqs/data/sampleby.html
>>
>>
>> On Fri, Apr 20, 2012 at 9:55 PM, Caliph Omar Moumin
>> <sheikmoumin@yahoo.com> wrote:
>>
>>> I am having difficult in selecting suitable sample from a stata dataset with multiple observations per Id variable. The data is many as 27000 observations. But there are many id variable with multiple observation, and more than 15 variables, for example if variable var1 is the id variable and it has observation “A” which  is repeated 10 times, I want a random selection which if it selects observation "A" in var1, then it selects all observations of “ A”, not only once, but 10 times in this case.
>>

*
*   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