I am trying to produce a line graph with separate groups but am having a couple of challenges with importing and reshaping the data from wide to long form.
The data has variable names in numerical form (i.e. number of months prior to and following an event). If I import the excel file I lose the variable names – ie replaced with the excel column letters. Alternatively, if I transpose the data in excel I can obtain the months as a variable. However, I then have a challenge transposing event names to become observations
Eg excel cells look like this
event -2 -1 0
United Nations Sustainable Development Summit 62 42 228
Volkswagen emissions scandal 49 41 2071
Once imported the data becomes
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str45 event byte(B C) int D
"United Nations Sustainable Development Summit" 62 42  228
"Volkswagen emissions scandal"                  49 41 2071
end
So, instead I’m inverting the file in excel (and changing the “event” heading to “month") and importing to produce
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte month int(UnitedNationsSustainableDevel Volkswagenemissionsscandal)
-2  62   49
-1  42   41
 0 228 2071
end
I then have a challenge of transposing to a long form (ie producing a variable of events containing each of the categories: UnitedNationsSustainableDevel Volkswagenemissionsscandal)
What I am hoping to achieve is a data set which looks like

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float media str45 event float month
  62 "United Nations Sustainable Development Summit" -2
  42 "United Nations Sustainable Development Summit" -1
 228 "United Nations Sustainable Development Summit"  0
  49 "Volkswagen emissions scandal"                  -2
  41 "Volkswagen emissions scandal"                  -1
2071 "Volkswagen emissions scandal"                   0
end
Which I can then graph using the command
Code:
twoway (line media month), by(event)
Thank you for your help, Dan