I don't understand why I'm getting the message
when I run the command
I have some code wherein I'm doing various data-munging, and I hit the error when I call -describe- with the "clear replace" option. It's baffling to me because the error only occurs when certain variables are described, and the error can be avoided by saving the data set. I'm not sure how I share the data in a way that makes this replicable, but perhaps someone will have an idea based on my code & output below. In my example I loop over 2 variables to show that the variable plays some (??) role, and I loop over `z' to control whether the data are saved, because that also seems to play some role. I also kept just 5 observations to make this even simpler. I'd appreciate any thoughts.
If helpful I can post some -trace- output.
Here's the output:
Code:
variable e not found r(111);
Code:
des `k' , clear replace
If helpful I can post some -trace- output.
Code:
... * data munging here ... tempfile TF des * list * , sep(0) assert x==0 qui forv z = 1/3 { noi di _newline(1) foreach k in ID x { preserve if `z'==1 sa "my_data", replace /* when `z'==1 I save a copy to disk */ if `z'==2 sa `TF', replace /* when `z'==2 I save a tempfile */ if `z'==3 noi di "on iteration z=3, no saving: " /* when `z'==3 no saving */ noi di "`z'; `k'; `c(filename)'" keep `k' noi des `k' , clear replace restore } }
Here's the output:
Code:
. tempfile TF . des * Variable Storage Display Value name type format label Variable label ----------------------------------------------------------------------------------------------------------------------------------- ID str6 %9s Household ID x float %9.0g daily nexus yarn per AE . list * , sep(0) +------------+ | ID x | |------------| 1. | 100001 0 | 2. | 100002 0 | 3. | 100003 0 | 4. | 100004 0 | 5. | 100005 0 | +------------+ . assert x==0 . qui forv z = 1/3 { 1; ID; my_data.dta 1; x; my_data.dta 2; ID; C:\Users\BHOLTE~1\AppData\Local\Temp\ST_6a70_000001.tmp 2; x; C:\Users\BHOLTE~1\AppData\Local\Temp\ST_6a70_000001.tmp on iteration z=3, no saving: 3; ID; work\my_original_data.dta on iteration z=3, no saving: 3; x; work\my_original_data.dta variable e not found r(111); end of do-file r(111);
Comment