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: How to generate variables by period


From   Xixi Lin <winnielxx@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: How to generate variables by period
Date   Mon, 11 Feb 2013 14:35:50 -0500

Wow!

Thank you so much!

Best,
Xixi Lin

On Mon, Feb 11, 2013 at 2:25 PM, Nick Cox <njcoxstata@gmail.com> wrote:
> No loop needed.
>
> bysort period : gen bench = 4/_N
>
> On Mon, Feb 11, 2013 at 7:18 PM, Xixi Lin <winnielxx@gmail.com> wrote:
>
>> I want to generate a benchmark, which equals 4/n, while n is the
>> number of observations and changes for each period out of 120 periods.
>> For example,
>> period 1: n=2000, benchmark=4/2000
>> period 2: n=3000, benchmark=4/3000
>> ......
>> period 120: n=1800, benchmark=4/1800
>>
>> How can I generate this benchmark more efficiently, for instance, write a loop?
> *
> *   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index