Transcription of Saving and printing output—log files
1 15 Saving and printing output log and closing to an existing and resuming comments in only what you log-button multiple log files for simultaneous OverviewStata can record your session into a file called a log file but does not start a log automatically; youmust tell Stata to record your session. By default, the resulting log file contains what you type and whatStata produces in response, recorded in a format called Stata Markup and Control Language (SMCL);see [P]smcl. The file can be printed or converted to plain text for incorporation into documents youcreate with your word start a log.
2 Log usingfilenameYour session is now being recordedin temporarily stop logging:Temporarily stop:. log offResume:. log onTo stop logging and close the file:. log closeYou can now type:. you canload into your word can also create a PDF Windows or Mac:. ways to start logging:append to an existing log:. log usingfilename, appendreplace an existing log:. log usingfilename, replaceUsing the GUI:To start a log:click on theLogbuttonTo temporarily stop logging:click on theLogbutton, and chooseSuspendTo resume:click on theLogbutton, and chooseResumeTo stop logging and close the file:click on theLogbutton, and chooseCloseTo print previous or current log.
3 SelectFile > , choose file,right-click on the Viewer, and selectPrintAlso,cmdlogwill produce logs containing solely what you typed logs that, although not containingyour results, are sufficient to re-create the start a command-only log:. cmdlog usingfilenameTo stop logging and close the file:. cmdlog closeTo re-create your session:. [ U ] 15 Saving and printing output log Starting and closing logsWith great foresight, you begin working in Stata and typelog using session(or click on theLogbutton) before starting your work.
4 Log using sessionname: <unnamed>log: C:\example\ type: smclopened on: 17 Mar 2013, 12:35:08. use (1980 Census data by state). tabulate region [freq=pop]CensusregionFreq. Percent ,135,283 Cntrl58,865,670 ,734,029 ,172,490 ,907,472 summarize median_ageVariableObs Mean Std. Dev. Min Maxmedian_age50 log closename: <unnamed>log: C:\example\ type: smclclosed on: 17 Mar 2013, 12:35:38 There is now a file your disk.
5 If you were to look at it in a text editor orword processor, you would see something like this:{smcl}{com}{sf}{ul off}{txt}{.-}name: {res}<unnamed>{txt}log: {res}C:\example\ {txt}log type: {res}smcl{txt}opened on: {res}17 Mar 2013, 12:35:08{com}. use {txt}(1980 Census data by state){com}. tabulate region [freq=pop]{txt}Census {c |}region {c |} Freq. Percent Cum.{hline 12}{c +}{hline 35}NE {c |}{res} 49,135,283 {txt} N Cntrl {c |}{res} 58,865,670 (output omitted)What you are seeing isSMCL, which Stata understands.
6 Here is the result of typing the file usingStata stypecommand:[ U ] 15 Saving and printing output log files 3. type : <unnamed>log: C:\example\ type: smclopened on: 17 Mar 2013, 12:35:08. use (1980 Census data by state). tabulate region [freq=pop]CensusregionFreq. Percent ,135,283 Cntrl58,865,670 ,734,029 ,172,490 ,907,472 summarize median_ageVariableObs Mean Std. Dev. Min Maxmedian_age50 log closename: <unnamed>log: C:\example\ type: smclclosed on: 17 Mar 2013, 12:35 you will see is a perfect copy of what you previously saw.
7 If you use Stata to print the file,you will get a perfect printed copy, can be translated to plain text, which is a format more useful for inclusion into aword processing document. If you , Stata will text and store the result :. translate resulting like this:----------------------------------- ---------------------------------------- ----name: <unnamed>log: C:\example\ type: smclopened on: 17 Mar 2013, 12:35:08. use (1980 Census data by state). tabulate region [freq=pop]Census |region | Freq.
8 Percent +-----------------------------------NE | 49,135,283 Cntrl | 58,865,670 | 74,734,029 (output omitted)When you usetranslateto , notalready exist:4 [ U ] 15 Saving and printing output log files. translate already existsr(602);If the file does already exist and you wish to overwrite the existing copy, you can specify thereplaceoption:. translate , replaceSee [R]translatefor more Windows and Mac, you can also convert yourSMCL file to aPDFto share it more easily withothers.
9 Translate [R]translatefor more you prefer, you can skip theSMCLand create text logs directly, either by specifying that youwant the log intextformat,. log using session, textor by specifying that the file to be created be :. log using Appending to an existing logStata never lets you accidentally write over an existing log file. If you have an existing log fileand you want to continue logging, you have three choices: create a new log file append the new log onto the existing log file by typinglog usinglogname, append replace the existing log file by typinglog usinglogname, replaceFor example, if you have an existing log file , you might type.
10 Log using session, appendto append the new log to the end of the existing log file, Suspending and resuming loggingOnce you have started logging your session, you can turn logging on and off. When you turnlogging off, Stata temporarily stops recording your session but leaves the log file open. When youturn logging back on, Stata continues to record your session, appending the additional record to theend of the that the first time something interesting happens, you typelog using results(or click onLogand ).