I am attempting to loop a series of analyses to produce a series of output files with a new, different name from each loop. This work uses a longitudinal dataset that includes data from each sequential day having been added over a period of time. I would like to use the new, daily date variable value (here called "datevariable") for each past day to name each such file.
In other words, I want to create output using data prior to date q, and save that output; then create and save output using data prior to date q + 1; then same for date q + 2; etc. etc.
I have unsuccessfully attempted to use the following general approach:
foreach x of varlist datevariable {
logistic outcome predictor1 predictor2 if datevariable<`x'
***(...followed by lengthy post-regression code, producing a table of values...)***
save "analytic file as of `x'.dta"
}
*
Code appears to run until reaching the command to save the file. Then I receive the error message "number of quadrature points must be less than or equal to number of obs." I believe that simply putting the `x' value for the running date in the save command is the part that doesn't work, but I am not sure.
I will be happy to use some other file naming convention such as simple, serial file numbers if that is all that will work in Stata. Hopefully, what I seek to do is possible, otherwise I will have to write a separate code set for each of hundreds of past days.
Notes: I am working in Stata 12.1. I cannot export data due to data sharing agreements.
Thank you for any advice you can provide - HC
In other words, I want to create output using data prior to date q, and save that output; then create and save output using data prior to date q + 1; then same for date q + 2; etc. etc.
I have unsuccessfully attempted to use the following general approach:
foreach x of varlist datevariable {
logistic outcome predictor1 predictor2 if datevariable<`x'
***(...followed by lengthy post-regression code, producing a table of values...)***
save "analytic file as of `x'.dta"
}
*
Code appears to run until reaching the command to save the file. Then I receive the error message "number of quadrature points must be less than or equal to number of obs." I believe that simply putting the `x' value for the running date in the save command is the part that doesn't work, but I am not sure.
I will be happy to use some other file naming convention such as simple, serial file numbers if that is all that will work in Stata. Hopefully, what I seek to do is possible, otherwise I will have to write a separate code set for each of hundreds of past days.
Notes: I am working in Stata 12.1. I cannot export data due to data sharing agreements.
Thank you for any advice you can provide - HC
Comment