Hi all, was hoping someone could please help me as this is important for my THESIS.
I have data in this long format. In the total data the ID ranges from 1001 to 2019. The Year ranges from 2006 to 2016.
An example of what the first 14 rows of data look like are below.
I have tried several times to reshape the data wide. I used the following ''reshape wide VARIABLE A, i(ID) j(YEAR).
Unfortunately, this does not work and the stata output says
----- ''values of variable year not unique within ID.
Your data are currently long. You are performing a reshape wide. You specified i(ID) and j(YEAR). There are observations within i(ID) with the same value of
j(YEAR). In the long data, variables i() and j() together must uniquely identify the observations-----
I thought to change ID numbering from 4 digits to 1 digit to prevent ID and YEAR having the same numbers further down the data. So I changed the ID from 1001 to 1, and 1002 to 2. 1003 to 3 and so on. I then attempted to reshape again but it still did not work and the output again was
----- ''values of variable year not unique within ID.
Your data are currently long. You are performing a reshape wide. You specified i(ID) and j(YEAR). There are observations within i(ID) with the same value of
j(YEAR). In the long data, variables i() and j() together must uniquely identify the observations-----
I really need to reshape this data wide so that I have VARIABLE A_YEAR columns. All data is numerical! No strings.
Please could someone kindly help me out?
Many thanks
I have data in this long format. In the total data the ID ranges from 1001 to 2019. The Year ranges from 2006 to 2016.
An example of what the first 14 rows of data look like are below.
I have tried several times to reshape the data wide. I used the following ''reshape wide VARIABLE A, i(ID) j(YEAR).
Unfortunately, this does not work and the stata output says
----- ''values of variable year not unique within ID.
Your data are currently long. You are performing a reshape wide. You specified i(ID) and j(YEAR). There are observations within i(ID) with the same value of
j(YEAR). In the long data, variables i() and j() together must uniquely identify the observations-----
ID | VARIABLE A | YEAR |
1001 | 200 | 2015 |
1001 | 333 | 2016 |
1001 | 444 | 2017 |
1002 | 555 | 2010 |
1003 | 662 | 2011 |
1003 | 456 | 2012 |
1003 | 783 | 2014 |
1004 | 459 | 2015 |
1005 | 239 | 2016 |
1005 | 348 | 2016 |
1006 | 452 | 2012 |
1006 | 324 | 2013 |
1008 | 365 | 2014 |
1009 | 216 | 2011 |
I thought to change ID numbering from 4 digits to 1 digit to prevent ID and YEAR having the same numbers further down the data. So I changed the ID from 1001 to 1, and 1002 to 2. 1003 to 3 and so on. I then attempted to reshape again but it still did not work and the output again was
----- ''values of variable year not unique within ID.
Your data are currently long. You are performing a reshape wide. You specified i(ID) and j(YEAR). There are observations within i(ID) with the same value of
j(YEAR). In the long data, variables i() and j() together must uniquely identify the observations-----
I really need to reshape this data wide so that I have VARIABLE A_YEAR columns. All data is numerical! No strings.
Please could someone kindly help me out?
Many thanks
ID | VARIABLE A | YEAR |
1 | 200 | 2015 |
1 | 333 | 2016 |
1 | 444 | 2017 |
2 | 555 | 2010 |
3 | 662 | 2011 |
3 | 456 | 2012 |
3 | 783 | 2014 |
4 | 459 | 2015 |
5 | 239 | 2016 |
5 | 348 | 2016 |
6 | 452 | 2012 |
6 | 324 | 2013 |
8 | 365 | 2014 |
9 | 216 | 2011 |
Comment