Hi,
I am working with the following variables:
And I am trying to transform the structure such that each year has month observations from months 1-12. I tried the following code:
but this only results in a missing mdate value and does not add the missing month observations. Is there another way to proceed here?
Thank you.
I am working with the following variables:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float month double(year ID) float count 1 1990 7123 . 1 1991 7123 . 1 1992 7123 . 1 1993 7123 . 1 1994 7123 . 1 1995 7123 . 1 1996 7123 . 1 1997 7123 . 1 1998 7123 . 1 1999 7123 . 1 2000 7123 . 1 2001 7123 . 1 2002 7123 . 1 2003 7123 . 1 2004 7123 . 1 2005 7123 . 1 2006 7123 . 1 2007 7123 . 1 2008 7123 . 1 2009 7123 . 1 2010 7123 . 1 2011 7123 . 1 2012 7123 . 1 2013 7123 . 1 2014 7123 . 1 2015 7123 . 1 2016 7123 . 1 2017 7123 . 1 2018 7123 . 1 2019 7123 . end
Code:
gen mdate = ym(year, month) format mdate %tm tsset ID mdate fillin ID mdate
Thank you.
Comment