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]

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

From   "Jessica Kopsic" <>
Subject   st: How to refer to different time periods when writing code
Date   Fri, 6 Jan 2012 18:18:30 -0500

Dear List Members,

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.

Thank you, as always, for your excellent assistance!


*   For searches and help try:

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