I am using Stata version 15.1 and would like to create a file on disk and append the contents of the current dataset in memory to the file on each iteration of a loop:
The scenario is as follows:
Code:
levelsof catVar, local(levels)
foreach l of local levels {
preserve
drop if catVar != `l'
// here I wish to create some new variables
// based on the values of the current variables
// in memory, and append to a file on disk.
restore
}
If there is no way of doing this I would appreciate any alternative suggestions, such as iterating overall all current rows in the dataset and writing them out one-by-one.
0 Response to Append to a file on disk on each iteration of a loop
Post a Comment