Dear All,
I am trying to create a new variable based on values from existing variables. Below is a snapshot of my dataset. I have variables X1-X8, and i'm trying to create variable X, which takes the value GR 2007 in the first row, GR 2008 in the second row, etc. There are no two values on the same row.
I tried gen X=X1 | X2 | X3 ..., but then X takes only the value 1. How do i go about it?
Thanks very much for your help, much appreciated!
Magda
I am trying to create a new variable based on values from existing variables. Below is a snapshot of my dataset. I have variables X1-X8, and i'm trying to create variable X, which takes the value GR 2007 in the first row, GR 2008 in the second row, etc. There are no two values on the same row.
I tried gen X=X1 | X2 | X3 ..., but then X takes only the value 1. How do i go about it?
Thanks very much for your help, much appreciated!
Magda
country | year | X1 | X2 | X3 | X4 | X5 | X6 | X7 | X8 | X |
GR | 2007 | 1.17 | ||||||||
GR | 2008 | 0.70 | ||||||||
GR | 2009 | 1.06 | ||||||||
GR | 2010 | 0.50 | ||||||||
GR | 2011 | 0.26 | ||||||||
GR | 2012 | 0.45 | ||||||||
GR | 2013 | 0.80 | ||||||||
GR | 2014 | 0.47 | ||||||||
IE | 2007 | 1.07 | ||||||||
IE | 2008 | 0.78 | ||||||||
IE | 2009 | 0.50 | ||||||||
IE | 2010 | 0.36 | ||||||||
IE | 2011 | 0.23 | ||||||||
IE | 2012 | 0.20 | ||||||||
IE | 2013 | 0.15 | ||||||||
IE | 2014 | 0.36 | ||||||||
IT | 2007 | 5.03 | ||||||||
IT | 2008 | 4.73 | ||||||||
IT | 2009 | 5.42 | ||||||||
IT | 2010 | 5.04 | ||||||||
IT | 2011 | 5.22 | ||||||||
IT | 2012 | 4.72 | ||||||||
IT | 2013 | 4.51 | ||||||||
IT | 2014 | 4.42 |
Comment