I have a do-file about 1000 lines in length. The data used has 54 observations and 448 variables. Near the end of the do-file, I attempt to generate a new variable with "generate" called "NetToGross" (which would be the 449th variable). The command does not produce an error code, but it does not appear in the variable list after running the do-file up to that point. I also have a summarize command that shows the variable has 0 observations. However, when I run the command individually after running all previous commands in the do-file, it works without any issues.
Here is the Stata output when running the do-file up to that point:
Right after that, I highlight the same commands in the do-file and click "execute." When I do that, the output changes:
Why would this command work when running individually, but not with the rest of the do-file?
Here is the Stata output when running the do-file up to that point:
Code:
*** NTG = 1 - (FREERIDER + SPILLOVER (0)) generate NetToGross = (1 - freerider + 0) summarize NetToGross [iweight = weight] Variable | Obs Weight Mean Std. dev. Min Max -------------+----------------------------------------------------------------- NetToGross | 0 0 *** NTG SCORE IS EQUAL TO 0.816 e end of do-file
Code:
do "C:\Users\JOSEPH~1\AppData\Local\Temp\STD35b8_000000.tmp" generate NetToGross = (1 - freerider + 0) (30 missing values generated) summarize NetToGross [iweight = weight] Variable | Obs Weight Mean Std. dev. Min Max -------------+----------------------------------------------------------------- NetToGross | 24 24.5142857 .8157761 .1853577 .5 1 end of do-file