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]

st: lag variable in panel if missing data


From   thomas bourveau <[email protected]>
To   [email protected]
Subject   st: lag variable in panel if missing data
Date   Tue, 4 Dec 2012 14:10:27 +0100

Dear readers,

I am currently working with a dataset where I have a company ID, the
date, and a consumption variable.

I am working in panel and, for each day, I need to generate a variable
that is the difference between the current value of consumption, and
its value one year before. (It's like an annual change).

This stata code looks like that:

generate difference = consumption - l364.consumption

The issue is that my dataset is built using calendar days. Thus, very
often, the l.364.consumption is nul because firms do not produce /
spend money during the week-ends.

I was wondering if it exists a command in panel that would
automatically tell stata to take the closest existing variable if
l364.consumption is nul. Can I also restrict that to a limited number
of days (e.g 3 or 5 days before the current date) ?

Thanks in advance

--
Thomas Bourveau
[email protected]
0637573925
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index