Hi there,
I am using Stata 15.1 on windows 10 for a dissertation project and am in the process of converting world bank excel data into Stata. I have created IDs for country names (unit_id) and Series names (s_id) in the excel spreadsheet.
When I try to reshape the data using "reshape long yr, i(unit_id s_id) j(time)" I am met with the following error:
variable id does not uniquely identify the observations
Your data are currently wide. You are performing a reshape long. You specified i(unit_id s_id) and j(time). In the current wide form,
variable unit_id s_id should uniquely identify the observations. Remember this picture:
long wide
+---------------+ +------------------+
| i j a b | | i a1 a2 b1 b2 |
|---------------| <--- reshape ---> |------------------|
| 1 1 1 2 | | 1 1 3 2 4 |
| 1 2 3 4 | | 2 5 7 6 8 |
| 2 1 5 6 | +------------------+
| 2 2 7 8 |
+---------------+
Typing the "reshape error" command gives me the output:
(note: j = 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992
> 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020)
i (s_id unit_id) indicates the top-level grouping such as subject id.
The data are currently in the wide form; there should be a single
observation per i.
5 of 1349 observations have duplicate i values:
+----------------+
| s_id unit_id |
|----------------|
1345. | . . |
1346. | . . |
1347. | . . |
1348. | . . |
1349. | . . |
+----------------+
(data now sorted by s_id unit_id)
Could anyone point out where I am going wrong with this? I have attached my excel data and do file for your viewing.
Thanks in advance!
Related Posts with Trouble Reshaping panel data from Wide to long.
Generate mean and median test results in StataDear Stata Users: I am trying to generate mean and median test results in Stata. Thanks to Kain Chen…
Specification of funnel plot with -funnelcompar-Hi Statalisters I want to assess county differences in medication rates in Norway to detect outlier…
Test for differences in Medians for Multiple Variables Using qregDear Stata Users: I would like to Test for differences in Medians for Multiple Variables Using qreg …
Generating a new variable based on several specified conditionsDear Stata-Community, I am currently working on a paper in which I want to create a variable that in…
Panel data with fixed effects model having dummy/time-invariant variables in data setGreetings, I'm trying to conduct FE-model test on my panel data set. The panel consists of 116 comp…
Subscribe to:
Post Comments (Atom)
0 Response to Trouble Reshaping panel data from Wide to long.
Post a Comment