Using a forvalues
loop, I am merging a list of 400 individual datasets.
These datasets can be one of 10 distinct values (defined by a variable in the dataset): depending on the dataset, I would merge
with a different dataset. For example, if Player 90 was type 9, I would want to merge with Type_9.dta
rather than Type_8
or Type_7
.
What I want is something like this:
forvalues x = 1/400 {
use "player_`x'.dta"
* some way to turn the value of player type into a local macro l *
merge 1:1 using "type_`l'.dta"
}
How can i get the variable type into a macro that changes for each type through the loop?