Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re: st: How to refer to different time periods when writing code

From   Nick Cox <>
Subject   Re: st: How to refer to different time periods when writing code
Date   Sat, 7 Jan 2012 08:25:00 +0000

. help subscripting (to learn about [_n - 1] etc.)
. help varlist (for time-series operators: better for panel data)


On Fri, Jan 6, 2012 at 11:18 PM, Jessica Kopsic <> wrote:

> I'm new to using Stata with panel data and time series. I'm trying to
> create a variable that refers to different time periods.
> For each day, I have two questions:
> Did you eat an apple today? (yes/no)
> Did you eat an orange yesterday? (yes/no)
> Foe each individual for each day I would like to create a variable called
> Fruit, that would tell how many pieces of fruit a person had each day. But
> I'm stuck because orange is referring to the previous day. I do have a
> variable identifying the time periods - "Day" with values  1, 2, 3, etc.
> So if on Day 3 someone answered yes to the apple question and on Day 4
> someone answered yes to the orange question, the value for Fruit for Day 3
> would be 2.
> I'm not certain how to tell Stata "the previous day" or "the next day"
> when computing the variable.

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index