Hi, I'm trying to do something like the below, where I collapse to get a sum of the "hours" variable by respondent ID, and then proceed to do a bunch of other data processing (which renders the dataset organized in a way that I can't calculate the "hours" in the correct way) before merging in the "hours" var back in.
The problem that I think is happening is that when I restore the data, the tempfile is not kept in memory--I get the error "invalid file specification" during the merge--but it may be due to something else with how I'm saving the tempfile?
The problem that I think is happening is that when I restore the data, the tempfile is not kept in memory--I get the error "invalid file specification" during the merge--but it may be due to something else with how I'm saving the tempfile?
Code:
use maindata, clear preserve collapse (sum) hours, by(resp_id) tempfile hoursdata save `hoursdata' restore // // a bunch of other data cleaning happens // merge 1:m resp_id using `hoursdata'
Comment