I have a multidimensional panel structure - panel units are states, time variable is year, and there's another variable called valuename which has a corresponding metric value.
Dataex:
I want each observation in the data to be:
state - year - number of volunteers - volunteer hours, as such:
I accomplished this by manually creating and subscripting NH and NV. I have many more possible value for valuename, so this is not a realistic option, and I'm looking for a more elegant solution.
Dataex:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str32 valuename double metric int year str20 state_name "Number of volunteers" 971.2646819 2004 "Alabama" "Number of volunteers" 1113.977571 2005 "Alabama" "Number of volunteers" 885.8076744 2006 "Alabama" "Number of volunteers" 842.0982383 2007 "Alabama" "Number of volunteers" 891.8058441 2008 "Alabama" "Number of volunteers" 927.275827 2009 "Alabama" "Number of volunteers" 974.2450833 2010 "Alabama" "Number of volunteers" 910.4783982 2011 "Alabama" "Number of volunteers" 900.4874115 2012 "Alabama" "Number of volunteers" 921.3599062 2013 "Alabama" "Number of volunteers" 905.0239872 2014 "Alabama" "Number of volunteers" 833.897401 2015 "Alabama" "Volunteer Hours in millions" 110.3327496 2004 "Alabama" "Volunteer Hours in millions" 174.2784784 2005 "Alabama" "Volunteer Hours in millions" 117.3132626 2006 "Alabama" "Volunteer Hours in millions" 93.3599999 2007 "Alabama" "Volunteer Hours in millions" 122.7068316 2008 "Alabama" "Volunteer Hours in millions" 91.95548496 2009 "Alabama" "Volunteer Hours in millions" 106.8859298 2010 "Alabama" "Volunteer Hours in millions" 100.8100441 2011 "Alabama" "Volunteer Hours in millions" 102.9366705 2012 "Alabama" "Volunteer Hours in millions" 116.4178635 2013 "Alabama" "Volunteer Hours in millions" 125.9858016 2014 "Alabama" "Volunteer Hours in millions" 98.70755004 2015 "Alabama" end
state - year - number of volunteers - volunteer hours, as such:
Code:
. list +---------------------------------------+ | state_~e year NV NH | |---------------------------------------| 1. | Alabama 2004 971.2647 110.3327 | 2. | Alabama 2005 1113.978 174.2785 | 3. | Alabama 2006 885.8077 117.3133 | 4. | Alabama 2007 842.0983 93.36 | 5. | Alabama 2008 891.8058 122.7068 | |---------------------------------------| 6. | Alabama 2009 927.2758 91.95548 | 7. | Alabama 2010 974.2451 106.8859 | 8. | Alabama 2011 910.4784 100.81 | 9. | Alabama 2012 900.4874 102.9367 | 10. | Alabama 2013 921.3599 116.4179 | |---------------------------------------| 11. | Alabama 2014 905.024 125.9858 | 12. | Alabama 2015 833.8974 98.70755 | +---------------------------------------+
Comment