I have a municipality-specific dataset that looks like this:
I created the id variable to help with the reshaping process. We are trying to reshape this dataset into something like this:
The code does not work.
Is there a way to tell stata that we want a new variable for each observation and that it should shorten the variable name/remove white space between words wherever required? Thank you so much!
We have 7000+ similar CSV files titled "municipalityname-data.csv," so doing it manually is not possible. Ideally, we would reshape all these files, generate a variable for the municipality name in each file, and then append all the files. Not sure if it's the most efficient way to do this.
label2 | abs | pc | id |
Totale generale delle Entrate | 23936646 | 37874.44 | 1 |
Entrate correnti di natura tributaria, contributiva e perequativa | 290295.81 | 459.32883 | 2 |
Imposte,tasse e proventi assimilati | 290295.81 | 459.3288 | 3 |
Compartecipazioni di tributi | 0 | 0 | 4 |
Totale generale delle Entrate_abs | Totale generale delle Entrate_pc | Entrate correnti di natura tributaria, contributiva e perequativa_abs | Entrate correnti di natura tributaria, contributiva e perequativa_pc | Imposte,tasse e proventi assimilati_abs | Imposte,tasse e proventi assimilati_pc | Compartecipazioni di tributi_abs | Compartecipazioni di tributi_pc |
23936646 | 37874.44 | 290295.81 | 459.32883 | 290295.81 | 459.3288 | 0 | 0 |
Code:
reshape wide pc abs, i(id) j(id)
Is there a way to tell stata that we want a new variable for each observation and that it should shorten the variable name/remove white space between words wherever required? Thank you so much!
We have 7000+ similar CSV files titled "municipalityname-data.csv," so doing it manually is not possible. Ideally, we would reshape all these files, generate a variable for the municipality name in each file, and then append all the files. Not sure if it's the most efficient way to do this.
Comment