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, is already up and running.

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

Re: st: Stacking data per day

From   Nick Cox <>
Subject   Re: st: Stacking data per day
Date   Mon, 17 Oct 2011 10:13:05 +0100

For this problem I would not turn to -stack-.
Your data structure is already long and lengthening it will not help.

It sounds as if you need -egen- with -by:-.

bysort day : egen pl_total = total(pl)


egen pl_total = total(pl), by(day)

are indicative examples. Look at the help for -egen-.


On Mon, Oct 17, 2011 at 10:02 AM, Julian Runge <> wrote:

> I am encountering a problem when trying to stack data in daily
> intervals. I guess this is just a basic problem, but after quite some
> effort I haven't been able to figure out how to do it. My data set
> contains profits/losses (variable pl) from a permanently ongoing
> trading game. That means, there can be several profit/loss events on
> the same day and even in the same minute (the time variable contains
> minutes, but not seconds). So, when I try to assign the data set a
> panel data structure, this is denied due to "repeated time values
> within panel". I wish to calculate the daily sums of pl. I tried to
> use the "stack" command, but wasn't able to formulate an if-expression
> telling Stata to stack the data for each day.
*   For searches and help try:

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