I want to save some output results using the -log- command. This works fine if I use -log- as in the example below: the command lines are shown above the results in the smcl-file (e.g. sum ... and reg ...) and consequently output is easily intrepretable.
Commands:
Code:
clear sysuse auto log using "Output-testA.smcl", replace nomsg sum price mpg weight length rep78 reg price mpg weight length i.rep78 log close translate "Output-testA.smcl" "Output-testA.pdf", translator(smcl2pdf)
Code:
. sum price mpg weight length rep78 Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- price | 74 6165.257 2949.496 3291 15906 mpg | 74 21.2973 5.785503 12 41 weight | 74 3019.459 777.1936 1760 4840 length | 74 187.9324 22.26634 142 233 rep78 | 69 3.405797 .9899323 1 5 . reg price mpg weight length i.rep78 Source | SS df MS Number of obs = 69 -------------+---------------------------------- F(7, 61) = 7.25 Model | 262008114 7 37429730.6 Prob > F = 0.0000 Residual | 314788844 61 5160472.86 R-squared = 0.4542 -------------+---------------------------------- Adj R-squared = 0.3916 Total | 576796959 68 8482308.22 Root MSE = 2271.7 ------------------------------------------------------------------------------ price | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- mpg | -126.8367 84.49819 -1.50 0.138 -295.8012 42.12791 weight | 5.186695 1.163383 4.46 0.000 2.860367 7.513022 length | -124.1544 40.07637 -3.10 0.003 -204.292 -44.01671 | rep78 | 2 | 1137.284 1803.332 0.63 0.531 -2468.701 4743.269 3 | 1254.642 1661.545 0.76 0.453 -2067.823 4577.108 4 | 2267.188 1698.018 1.34 0.187 -1128.208 5662.584 5 | 3850.759 1787.272 2.15 0.035 276.8886 7424.63 | _cons | 14614.49 6155.842 2.37 0.021 2305.125 26923.86 ------------------------------------------------------------------------------ . log close
Commands:
Code:
clear sysuse auto forvalues i = 1/3 { log using "Output-testB`i'.smcl", replace nomsg sum price mpg weight length rep78 reg price mpg weight length i.rep78 log close translate "Output-testB`i'.smcl" "Output-testB`i'.pdf", translator(smcl2pdf) }
Code:
Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- price | 74 6165.257 2949.496 3291 15906 mpg | 74 21.2973 5.785503 12 41 weight | 74 3019.459 777.1936 1760 4840 length | 74 187.9324 22.26634 142 233 rep78 | 69 3.405797 .9899323 1 5 Source | SS df MS Number of obs = 69 -------------+---------------------------------- F(7, 61) = 7.25 Model | 262008114 7 37429730.6 Prob > F = 0.0000 Residual | 314788844 61 5160472.86 R-squared = 0.4542 -------------+---------------------------------- Adj R-squared = 0.3916 Total | 576796959 68 8482308.22 Root MSE = 2271.7 ------------------------------------------------------------------------------ price | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- mpg | -126.8367 84.49819 -1.50 0.138 -295.8012 42.12791 weight | 5.186695 1.163383 4.46 0.000 2.860367 7.513022 length | -124.1544 40.07637 -3.10 0.003 -204.292 -44.01671 | rep78 | 2 | 1137.284 1803.332 0.63 0.531 -2468.701 4743.269 3 | 1254.642 1661.545 0.76 0.453 -2067.823 4577.108 4 | 2267.188 1698.018 1.34 0.187 -1128.208 5662.584 5 | 3850.759 1787.272 2.15 0.035 276.8886 7424.63 | _cons | 14614.49 6155.842 2.37 0.021 2305.125 26923.86 ------------------------------------------------------------------------------
Thanks a lot,
Mike
0 Response to Logging results in forvalues-loop: command lines are not shown in output-logfile
Post a Comment