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: How to generate dummy for the following years
From
Ronnie Babigumira <[email protected]>
To
[email protected]
Subject
Re: st: How to generate dummy for the following years
Date
Thu, 26 Jul 2012 18:16:50 +0300
Umut
I think this kind of question is best answered if you show some data (and may be what you are trying to achieve). You could use the very helpful -writeinput- (-ssc install writeinput-) to do this.
Ronnie
--
010100100110111101101110011011100110100101100101
On Thursday, July 26, 2012 at 6:07 PM, umut senalp wrote:
> 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/
*
* 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/