Hello Statalist!
I am working with data that looks like this:
analys ticker
72 ATX
72 DMV
81 DMV
81 AZW
96 DMT
I am trying to create a dataset that, as a first step, has an observation for every day of the period (1Jan2007-31Dec2020) corresponding to each of these observations, like this
analys ticker date
72 ATX 1 Jan 2007
72 ATX 2 Jan 2007
.
.
.
72 ATX 31 Dec 2020
72 DMV 1 Jan 2007
72 DMV 2 Jan 2007
.
.
.
72 DMV 31 Dec 2020
and so on. This is only the first step and I will later also have to merge in other data, create running indicator variables, etc. and because the file size will blow up I have resorted to doing this via a for loop. I used the following code:
egen analysbyfirm = concat(ticker analys)
levelsof analysbyfirm, local(tickeranalyslevels)
foreach i of local tickeranalyslevels {
preserve
drop if analysbyfirm != `i'
expand 5114
gen date = mdy(12, 31, 2006) +_n
format date %td
append using experiment.dta
save experiment.dta, replace
restore
}
but at the end of the for loop Stata returns the error:
00BV70 invalid name
r(198);
I am very new to Stata and completely at a loss, any help would be deeply appreciated! Thank you!
I am working with data that looks like this:
analys ticker
72 ATX
72 DMV
81 DMV
81 AZW
96 DMT
I am trying to create a dataset that, as a first step, has an observation for every day of the period (1Jan2007-31Dec2020) corresponding to each of these observations, like this
analys ticker date
72 ATX 1 Jan 2007
72 ATX 2 Jan 2007
.
.
.
72 ATX 31 Dec 2020
72 DMV 1 Jan 2007
72 DMV 2 Jan 2007
.
.
.
72 DMV 31 Dec 2020
and so on. This is only the first step and I will later also have to merge in other data, create running indicator variables, etc. and because the file size will blow up I have resorted to doing this via a for loop. I used the following code:
egen analysbyfirm = concat(ticker analys)
levelsof analysbyfirm, local(tickeranalyslevels)
foreach i of local tickeranalyslevels {
preserve
drop if analysbyfirm != `i'
expand 5114
gen date = mdy(12, 31, 2006) +_n
format date %td
append using experiment.dta
save experiment.dta, replace
restore
}
but at the end of the for loop Stata returns the error:
00BV70 invalid name
r(198);
I am very new to Stata and completely at a loss, any help would be deeply appreciated! Thank you!

Comment