Sounds like a job for -merge-; basically,
make 92 files again and put them back together
correctly - something like this:
levelsof datasetnum, local(dsn)
local first : word 1 of `dsn'
foreach D in `dsn' {
keep if datasetnum==`D'
ren rank rank`D'
ren total total`D'
sort SMSAname
save tmp`D'
}
local dsn : list dsn-first
u tmp`first'
foreach D in `dsn' {
sort SMSAname
merge 1:1 SMSAname using tmp`D'
drop _merge
erase tmp`D'.dta
}
Assuming files tmp* don't exist.
hth,
Jeph
Eric Uslaner wrote:
Greetings,
I have a data set of 92 sets of crime rankings by SMSA. But whoever
put them together made a mess out of them (originally in Excel, but I
have them in Stata). The data set consists of about 230 SMSAs
(standard metropolitan statistical areas) and their crime totals and
ranks in 4 columns: data set number, SMSA name, total, rank--92 times
(one for each data set number) so I have about 30,000+ entries.
What I want to do is to create 92 * 2 variables so that the data set
would look like this:
SMSAname total1 rank1 total2 rank2...total92 rank92
ideally using SMSAname only once rather than 92 times. Any
suggestions as to how to do this would be greatly appreciated.
Thanks much,
Ric
* * For searches and help try: *
http://www.stata.com/help.cgi?search *
http://www.stata.com/support/statalist/faq *
http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/