I am currently working with data on different universities' metrics over time and need to change my data from long to wide format. So for each university, I currently have hundreds of rows, each of which has a university, which metric is measured, the year of the measurement, and its value. I am running into a couple of problems which I'm hoping to get some help on.
First I tried the reshape command of course, but because the year and metric name are not unique (i.e. each university also has the same year and metric name), I am unable to use the reshape command as together year and metric name do not uniquely identify observations. Is there a way to fix this?
To get around the first problem, I realized I could just isolate each university (by copying them into a new session of Stata, for example) and then simply reshape each university's data individually because once a single university is isolated, the metric name and year do uniquely identify observations. I've run into a couple of problems with this method, too, however. First, because the university names were encoded string values, I am losing the string part of the data when I reshape (Harvard University becomes just a 1, or whatever the encoded value was). Second, this process obviously will take a lot of time given the number of universities I have in the data set.
Hope this is clear!
Here is a very small sample of my current data: (sorry the formatting isn't perfect I didn't know the command to export it here cleanly)
Name Value Metricdescription Issueyear SchoolID PublicPrivate
Washington and Lee University 10.6 Student/faculty ratio 2002 3163 Private
Washington and Lee University 11.1 Student/faculty ratio 2003 3163 Private
Washington and Lee University 10.8 Student/faculty ratio 2004 3163 Private
Washington and Lee University 10.4 Student/faculty ratio 2005 3163 Private
Washington and Lee University 11.7 Student/faculty ratio 2006 3163 Private
Washington and Lee University 10.5 Student/faculty ratio 2007 3163 Private
Washington and Lee University 9.8 Student/faculty ratio 2008 3163 Private
Washington and Lee University 10.6 Student/faculty ratio 2009 3163 Private
Washington and Lee University 9.5 Student/faculty ratio 2010 3163 Private
Washington and Lee University 9.4 Student/faculty ratio 2011 3163 Private
Washington and Lee University 9.5 Student/faculty ratio 2012 3163 Private
Washington and Lee University 9.5 Student/faculty ratio 2013 3163 Private
Washington and Lee University 10.2 Student/faculty ratio 2014 3163 Private
Washington and Lee University 10.7 Student/faculty ratio 2015 3163 Private
Washington and Lee University 8.5 Student/faculty ratio 2016 3163 Private
Washington and Lee University 8.9 Student/faculty ratio 2017 3163 Private
Washington and Lee University 8.7 Student/faculty ratio 2018 3163 Private
Washington and Lee University 5.7 Student/faculty ratio 2019 3163 Private
Washington and Lee University 6.9 Student/faculty ratio 2020 3163 Private
Washington and Lee University Bar Passage rank 1994 3163 Private
Washington and Lee University Bar Passage rank 1995 3163 Private
Washington and Lee University Bar Passage rank 1996 3163 Private
Washington and Lee University Bar Passage rank 1997 3163 Private
Washington and Lee University Bar Passage rank 1998 3163 Private
Washington and Lee University Bar Passage rank 1999 3163 Private
Washington and Lee University Bar Passage rank 2000 3163 Private
Washington and Lee University Bar Passage rank 2001 3163 Private
Washington and Lee University Bar Passage rank 2002 3163 Private
Washington and Lee University Bar Passage rank 2003 3163 Private
Washington and Lee University Bar Passage rank 2004 3163 Private
Washington and Lee University Bar Passage rank 2005 3163 Private
Washington and Lee University Bar Passage rank 2006 3163 Private
Washington and Lee University Bar Passage rank 2007 3163 Private
Washington and Lee University Bar Passage rank 2008 3163 Private
Washington and Lee University Bar Passage rank 2009 3163 Private
Washington and Lee University 52 Bar Passage rank 2010 3163 Private
Washington and Lee University 117 Bar Passage rank 2011 3163 Private
Washington and Lee University 93 Bar Passage rank 2012 3163 Private
Washington and Lee University 175 Bar Passage rank 2013 3163 Private
Washington and Lee University 21 Bar Passage rank 2014 3163 Private
Washington and Lee University 177 Bar Passage rank 2015 3163 Private
Washington and Lee University 113 Bar Passage rank 2016 3163 Private
Washington and Lee University 26 Bar Passage rank 2017 3163 Private
Washington and Lee University 29 Bar Passage rank 2018 3163 Private
Washington and Lee University 66 Bar Passage rank 2019 3163 Private
Washington and Lee University 59 Bar Passage rank 2020 3163 Private
Yale University Acceptance rate 1994 3027 Private
Yale University Acceptance rate 1995 3027 Private
Yale University Acceptance rate 1996 3027 Private
Yale University Acceptance rate 1997 3027 Private
Yale University Acceptance rate 1998 3027 Private
Yale University Acceptance rate 1999 3027 Private
Yale University Acceptance rate 2000 3027 Private
Yale University Acceptance rate 2001 3027 Private
Yale University Acceptance rate 2002 3027 Private
Yale University Acceptance rate 2003 3027 Private
Yale University Acceptance rate 2004 3027 Private
Yale University Acceptance rate 2005 3027 Private
Yale University Acceptance rate 2006 3027 Private
Yale University Acceptance rate 2007 3027 Private
Yale University Acceptance rate 2008 3027 Private
Yale University Acceptance rate 2009 3027 Private
Yale University 7.6551946 Acceptance rate 2010 3027 Private
Yale University 8.0285459 Acceptance rate 2011 3027 Private
Yale University 6.7158283 Acceptance rate 2012 3027 Private
Yale University 7.9420107 Acceptance rate 2013 3027 Private
Yale University 8.3248386 Acceptance rate 2014 3027 Private
Yale University 9.3667046 Acceptance rate 2015 3027 Private
Yale University 8.9192025 Acceptance rate 2016 3027 Private
Yale University 9.7217203 Acceptance rate 2017 3027 Private
Yale University 9.4698355 Acceptance rate 2018 3027 Private
Yale University 8.3857442 Acceptance rate 2019 3027 Private
Yale University 6.852865 Acceptance rate 2020 3027 Private
Yale University Bar Passage rank 1994 3027 Private
Yale University Bar Passage rank 1995 3027 Private
Yale University Bar Passage rank 1996 3027 Private
Yale University Bar Passage rank 1997 3027 Private
Yale University Bar Passage rank 1998 3027 Private
Yale University Bar Passage rank 1999 3027 Private
Yale University Bar Passage rank 2000 3027 Private
Yale University Bar Passage rank 2001 3027 Private
Yale University Bar Passage rank 2002 3027 Private
Yale University Bar Passage rank 2003 3027 Private
Yale University Bar Passage rank 2004 3027 Private
Yale University Bar Passage rank 2005 3027 Private
Yale University Bar Passage rank 2006 3027 Private
Yale University Bar Passage rank 2007 3027 Private
Yale University Bar Passage rank 2008 3027 Private
Yale University Bar Passage rank 2009 3027 Private
Yale University 20 Bar Passage rank 2010 3027 Private
Yale University 16 Bar Passage rank 2011 3027 Private
Yale University 20 Bar Passage rank 2012 3027 Private
Yale University 8 Bar Passage rank 2013 3027 Private
Yale University 8 Bar Passage rank 2014 3027 Private
Yale University 12 Bar Passage rank 2015 3027 Private
Yale University 7 Bar Passage rank 2016 3027 Private
Yale University 10 Bar Passage rank 2017 3027 Private
Yale University 5 Bar Passage rank 2018 3027 Private
Yale University 8 Bar Passage rank 2019 3027 Private
Yale University 12 Bar Passage rank 2020 3027 Private
Arizona Summit Law School Acceptance rate 1994 3197 Private
Arizona Summit Law School Acceptance rate 1995 3197 Private
Arizona Summit Law School Acceptance rate 1996 3197 Private
Arizona Summit Law School Acceptance rate 1997 3197 Private
Arizona Summit Law School Acceptance rate 1998 3197 Private
Arizona Summit Law School Acceptance rate 1999 3197 Private
Arizona Summit Law School Acceptance rate 2000 3197 Private
Arizona Summit Law School Acceptance rate 2001 3197 Private
Arizona Summit Law School Acceptance rate 2002 3197 Private
Arizona Summit Law School Acceptance rate 2003 3197 Private
Arizona Summit Law School Acceptance rate 2004 3197 Private
Arizona Summit Law School Acceptance rate 2005 3197 Private
Arizona Summit Law School Acceptance rate 2006 3197 Private
Arizona Summit Law School Acceptance rate 2007 3197 Private
Arizona Summit Law School Acceptance rate 2008 3197 Private
Arizona Summit Law School Acceptance rate 2009 3197 Private
Arizona Summit Law School 67.445365 Acceptance rate 2010 3197 Private
Arizona Summit Law School Acceptance rate 2011 3197 Private
Arizona Summit Law School 69.650817 Acceptance rate 2012 3197 Private
Arizona Summit Law School 72.944759 Acceptance rate 2013 3197 Private
Arizona Summit Law School 84.96945 Acceptance rate 2014 3197 Private
Arizona Summit Law School 84.96945 Acceptance rate 2015 3197 Private
Arizona Summit Law School 68.858655 Acceptance rate 2016 3197 Private
Arizona Summit Law School 73.397717 Acceptance rate 2017 3197 Private
Arizona Summit Law School 64.090909 Acceptance rate 2018 3197 Private
Arizona Summit Law School Acceptance rate 2019 3197 Private
Arizona Summit Law School Acceptance rate 2020 3197 Private
Arizona Summit Law School Bar Passage rank 1994 3197 Private
Arizona Summit Law School Bar Passage rank 1995 3197 Private
Arizona Summit Law School Bar Passage rank 1996 3197 Private
Arizona Summit Law School Bar Passage rank 1997 3197 Private
Arizona Summit Law School Bar Passage rank 1998 3197 Private
Arizona Summit Law School Bar Passage rank 1999 3197 Private
Arizona Summit Law School Bar Passage rank 2000 3197 Private
Related Posts with Question about reshape
replicating an instrumented model in eregress and ivreg2 (or ivregress)Hi Stata people, I would like to replicate a model I am using in eregress (Stata 15 and up) with iv…
Replace values in each rowHi, In the following dataset: Code: * Example generated by -dataex-. To install: ssc install data…
replicating an instrumented model in eregress and ivreg2 (or ivregress)Hi Stata people, I would like to replicate a model I am using in eregress (Stata 15 and up) and ivr…
Stata 17 ptrendsHi, I'm a student working on a diff in diff using Stata 17's new didregress. I used the postestimati…
How to create a two-axis graph by using coefficient plotting?When I run this regression for coefficient plotting purposes Code: reghdfe wNET_PRO_MAR dkt_4 dkt_…
Subscribe to:
Post Comments (Atom)
0 Response to Question about reshape
Post a Comment