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: using loops in collapse command


From   Jocelyn Michael <[email protected]>
To   [email protected]
Subject   Re: st: using loops in collapse command
Date   Mon, 2 Apr 2012 11:46:17 -0400

Thank you.

J.

On Mon, Apr 2, 2012 at 10:45 AM, ming li <[email protected]> wrote:
> hi Michael,
> how about try this:
>
> net install dm71.pkg
> egen newwar=prod(value1), by(id)
>
> for more options, just help prod after installation
>
> Ming
>
> 2012/4/2 Jocelyn Michael <[email protected]>
>>
>> I am a new stata user and have been trying to write a loop to accomplish a task.
>>
>> My data looks like this:
>>
>>
>> id                 Year               Value 1
>> A               Jan1991             0.92
>> A               Feb1991             0.93
>> A               Mar1991             0.24
>> A               APr1991             0.83
>> ..
>> ..
>> B               Jan1991             0.67
>> B               Feb1991             0.45
>> ..
>>
>> What I am trying to achieve is to write a loop that multiplies value1
>> for each id and returns one number for each year - sort of like a
>> collapse command but instead of the sum, I want the product. That is
>> for A for 1991, (0.92*0.93*0.24*0.83).
>>
>> Any help is greatly appreciated.
>>
>> JM.
>> *
>> *   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/
>
>
>
>
> --
> 李明
> 北京大学元培学院 2008级金融本科
> 邮箱:[email protected]
> 手机:(86)151-2007-8720
>
> Nancy Li
> Candidate for Bachelor of Finance,Yuanpei College, Peking University
> Email:[email protected]
> Cell:(86)151-2007-8720
>
> *
> *   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