I have a Stata dataset (let's call it dataset1) which has data like this (fictitious data)
dataset1.dta
For each variable (variable1 through variable3) I need to summarize the above data and display the "max value and corresponding metro", the "min value and the corresponding metro"
and the average for each variable. Then I need to rearrange all this and display / export the summary in a format that looks something like this. Let's call it dataset2.
dataset2.dta
Any tips on how to turn dataset1 (which I already have in a nice format) into dataset2
Thanks in advance.
dataset1.dta
metro | metro_code | variable1 | variable2 | variable3 |
Akron | AKRO | 1 | 9 | 16 |
Albany | ALBA | 2 | 8 | 30 |
Albuquerque | ALBU | 3 | 7 | 10 |
Lehigh Valley | ALLE | 4 | 6 | 14 |
Anchorage | ANCH | 5 | 5 | 13 |
Anderson SC | ANDE | 6 | 3 | 12 |
Anderson IN | ANIN | 7 | 4 | 17 |
and the average for each variable. Then I need to rearrange all this and display / export the summary in a format that looks something like this. Let's call it dataset2.
dataset2.dta
Metro Name | Value | ||
variable1 | Max | Anderson IN | 7 |
Min | Akron | 1 | |
Avg | n/a | 4 | |
variable2 | Max | Akron | 9 |
Min | Anderson SC | 3 | |
Avg | n/a | 6 | |
variable3 | Max | Albany | 30 |
Min | Albuquerque | 10 | |
Avg | n/a | 16 |
Any tips on how to turn dataset1 (which I already have in a nice format) into dataset2
Thanks in advance.