Hi all,
A programme that I have been attempting to write relies on some calculations in a temporary data frame, whose results are stored in temporary variables in that data frame. I want to get these results back into the main data frame, but Stata simply will not copy the variables from the temporary frame into the main frame. I suspect that this is due to some built-in restrictions on temporary variables because the problem does not arise when I use normal variables. However, that is not an option in my setting, since my programme has to work in very generic settings, sometimes with hundreds of variables, and I cannot guarantee that a given variable name is not taken already.
As a simple working example, consider the following code:
This results in an error, because `sum_heatdd' is not copied into the main data frame. Is there any way to work around this restriction? (I also do not want to use a preserve/save/restore/merge workflow because I need to use the programme quite frequently and disk storage is painstakingly slow on the machine I have to work on.)
Any help would be greatly appreciated!
Cheers,
Joscha
A programme that I have been attempting to write relies on some calculations in a temporary data frame, whose results are stored in temporary variables in that data frame. I want to get these results back into the main data frame, but Stata simply will not copy the variables from the temporary frame into the main frame. I suspect that this is due to some built-in restrictions on temporary variables because the problem does not arise when I use normal variables. However, that is not an option in my setting, since my programme has to work in very generic settings, sometimes with hundreds of variables, and I cannot guarantee that a given variable name is not taken already.
As a simple working example, consider the following code:
Code:
sysuse citytemp
tempname newframe
frame put division heatdd, into(`newframe')
frame change `newframe'
tempvar sum_heatdd
collapse (sum) `sum_heatdd' = heatdd, by(division)
frame change default
frlink m:1 division, frame(`newframe')
frget `sum_heatdd', from(`newframe')
gen sum_heatdd = `sum_heatdd'
Any help would be greatly appreciated!
Cheers,
Joscha

Comment