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: Merging w/ substituting for years with missing values
From
David Kantor <[email protected]>
To
[email protected]
Subject
Re: st: Merging w/ substituting for years with missing values
Date
Fri, 02 Aug 2013 12:44:48 -0400
At 11:24 AM 8/2/2013, Leoni wrote:
I'm merging two panel datasets (A and B), one of which has few years
(A, I only need those), while the other has observations for many
years (B) -- but also has missing values for some of them. As most
of the variables that have missing values don't change a lot, I want
to tell STATA to use values from previous or following years (from
B) if they're missing for the exact year I need (those in A). This
sounds rather messy but is there an elegant way of doing this in STATA?
Any help is much appreciated.
Leoni
It's not too hard to write code to do that, but you may want to try
carryforward from SSC.
It goes forward, but you can use a negative date to trick it into
gong backward.
For filling inward, I like to do both forward and back, and see if
the values agree.
HTH
--David
*
* 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/