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: How to generate dummy for the following years


From   umut senalp <[email protected]>
To   <[email protected]>
Subject   st: How to generate dummy for the following years
Date   Thu, 26 Jul 2012 18:07:24 +0300

Dear Stata Listers,

I am using StataSE 12. I have an unbalanced data for over 2000 firms (covering the period 2003-2011) and I have a dummy variable for the firms' export status (Export=1 if firm have positive export value that year). While, a few firms observed for all 9 years (2003-2011), majority of them observed for minimum 2 years consecutively. 
I want to create a new set of dummy variables indicating the year that a firm started to export (Starter), 
one year before starting to export (Year_before),and for the following two years that the firm started to export which are Year_After and Two_Years_After. 
So, I want to generate 4 new dummies based on the firm's  Export status. In addition to that, I have some firms which are exporter for the all period that they are observable (means I do not know when they started to export), and I want to name them as Always_Exporter.

Since I am not so familiar with programming in Stata I tried following command but it failed, it was just for the firms that I have observation for 2003 onwards, anyway.
gen starter=0
replace starter=1 if export==0 in 2003 & export==1 in 2004

And I realised that this approach will not work since I need to do it for many times for following years to catch all starters.
 
Well, I think I need to use a program that includes loop but I don't know where to start to write the code. I would be glad if you could help me on this issue. I hope I've the issue clear enough.

Kind regards

Umut SENALP 		 	   		  
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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