<?xml version="1.0" encoding="UTF-8"?>
<!--Generated by Squarespace Site Server v5.11.81 (http://www.squarespace.com/) on Fri, 24 Feb 2012 04:14:29 GMT--><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rss="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:cc="http://web.resource.org/cc/"><rss:channel rdf:about="http://www.michaelnormanmitchell.com/stow/"><rss:title>Stata Tidbit of the Week</rss:title><rss:link>http://www.michaelnormanmitchell.com/stow/</rss:link><rss:description></rss:description><dc:language>en-US</dc:language><dc:date>2012-02-24T04:14:29Z</dc:date><admin:generatorAgent rdf:resource="http://www.squarespace.com/">Squarespace Site Server v5.11.81 (http://www.squarespace.com/)</admin:generatorAgent><rss:items><rdf:Seq><rdf:li rdf:resource="http://www.michaelnormanmitchell.com/stow/whats-new.html"/><rdf:li rdf:resource="http://www.michaelnormanmitchell.com/stow/the-statistical-software-components-ssc-archive.html"/><rdf:li rdf:resource="http://www.michaelnormanmitchell.com/stow/ssc-help-files-over-the-internet.html"/><rdf:li rdf:resource="http://www.michaelnormanmitchell.com/stow/stata-help-files-over-the-internet.html"/><rdf:li rdf:resource="http://www.michaelnormanmitchell.com/stow/stata-version-112.html"/><rdf:li rdf:resource="http://www.michaelnormanmitchell.com/stow/updating-tip.html"/><rdf:li rdf:resource="http://www.michaelnormanmitchell.com/stow/setting-return-messages-on.html"/><rdf:li rdf:resource="http://www.michaelnormanmitchell.com/stow/command-log-files.html"/><rdf:li rdf:resource="http://www.michaelnormanmitchell.com/stow/creating-multiple-log-files.html"/><rdf:li rdf:resource="http://www.michaelnormanmitchell.com/stow/log-files-and-do-files.html"/></rdf:Seq></rss:items></rss:channel><rss:item rdf:about="http://www.michaelnormanmitchell.com/stow/whats-new.html"><rss:title>What's new?</rss:title><rss:link>http://www.michaelnormanmitchell.com/stow/whats-new.html</rss:link><dc:creator>Michael Mitchell</dc:creator><dc:date>2011-05-11T03:00:39Z</dc:date><dc:subject></dc:subject><content:encoded><![CDATA[<p>When you update Stata, you are generally offered the chance to 
see what is new in your update via the <b><a href="http://www.stata.com/help.cgi?whatsnew">help whatsnew</a></b> command.
If you scroll to the very bottom of this help file you can see
that it not only contains information about the most recent updates,
but also updates dating all of the way back to version 6 of Stata.
For example, you can see a link to 
<b><a href="http://www.stata.com/help.cgi?whatsnew10to11">help whatsnew10to11</a></b>
that shows the features that were added in the update from Stata 10 to 11 in
2009. Or, for a flash back in time, have a look at 
<b><a href="http://www.stata.com/help.cgi?whatsnew6to7">help whatsnew6to7</a></b>
for a recap of the features added to Stata version 7 (compared to version 6).
Sometimes it is fun to see how much things have changed.</p>

<p>You can download the example data files from this tidbit 
(as well as all of the other tidbits) as shown below.
These will download all of the example data files into 
the current folder on your computer. (If you have done this
before, then you may need to specify <b>net get stowdata, replace</b> 
to overwrite the existing files.
<pre><blockquote>net from http://www.MichaelNormanMitchell.com/storage/stowdata
net get stowdata
</pre></blockquote>

If you have thoughts on this Stata Tidbit of the Week, you can 
post a comment. You can also send me an email at MichaelNormanMitchell 
and then the at sign and gmail dot com. 
If you are receiving this tidbit via email, you can find
the web version at 
<a href="http://www.MichaelNormanMitchell.com/">
http://www.michaelnormanmitchell.com/</a> .
</p>]]></content:encoded></rss:item><rss:item rdf:about="http://www.michaelnormanmitchell.com/stow/the-statistical-software-components-ssc-archive.html"><rss:title>The Statistical Software Components (SSC) archive</rss:title><rss:link>http://www.michaelnormanmitchell.com/stow/the-statistical-software-components-ssc-archive.html</rss:link><dc:creator>Michael Mitchell</dc:creator><dc:date>2011-04-20T03:00:14Z</dc:date><dc:subject></dc:subject><content:encoded><![CDATA[<p>The tidbit from last week described how you can view 
help files from the Statistical Software Components (SSC) archive
over the internet. This tidbit gives a little more information about the 
SSC archive.</p>

<p>While many people and organizations host their user written Stata programs
on their own web sites, the SSC archive 
(which is often called the Boston College Archive)
is one of the largest (if not in fact the largest) 
repository of Stata programs contributed by Stata enthusiasts 
from all over the world. The <b>ssc</b> command, which is built into Stata, is
a convenience command that easily connects you to this repository.

<p>For example, if you type the <b>ssc hot</b> command, shown
below, you will see the top 10 packages that have been 
recently downloaded. The output below shows the output
that I saw executing the command today (your results
will vary as the downloads for packages change over
time).</p>

<pre><blockquote>. ssc hot
Top 10 packages at SSC

        Feb2011    
  Rank   # hits    Package       Author(s)
  ----------------------------------------------------------------------
     1   4404.1    <a href="http://repec.org/help.php?c=outreg2">outreg2</a>       Roy Wada                                
     2   3098.8    <a href="http://repec.org/help.php?c=estout">estout</a>        Ben Jann                                
     3   1652.5    <a href="http://repec.org/help.php?c=ivreg2">ivreg2</a>        Christopher F Baum, Mark E Schaffer,    
                                   Steven Stillman                         
     4   1470.2    <a href="http://repec.org/help.php?c=psmatch2">psmatch2</a>      Barbara Sianesi, Edwin Leuven           
     5   1034.5    <a href="http://repec.org/help.php?c=gllamm">gllamm</a>        Sophia Rabe-Hesketh                     
     6   1025.3    <a href="http://repec.org/help.php?c=ranktest">ranktest</a>      Mark E Schaffer, Frank Kleibergen       
     7    910.8    <a href="http://repec.org/help.php?c=xtabond2">xtabond2</a>      David Roodman                           
     8    749.8    <a href="http://repec.org/help.php?c=tabout">tabout</a>        Ian Watson                              
     9    706.8    <a href="http://repec.org/help.php?c=xtivreg2">xtivreg2</a>      Mark E Schaffer                         
    10    630.0    <a href="http://repec.org/help.php?c=tabstatmat">tabstatmat</a>    Austin Nichols                          
  ----------------------------------------------------------------------
  (Click on package name for description)
</pre></blockquote>

<p>You can click on the names of the packages to view
its associated help file. Viewing these different help files
gives you a quick sense of the range, scope, and utility
of the programs located at SSC. (Note the names of the packages
in the output above are hot-linked to their online help files using
the technique illustrated in <a href="sschelp.html">the tidbit from last week<a>).

<p>You are not limited to just viewing the top 10 packages. For example,
you can use the <b>n()</b> option, as illustrated below, to control
how many packages you see. The example below shows the
top 100 packages recently downloaded (the output is omitted). 

<pre><blockquote>. ssc hot, n(100)</pre></blockquote>

<p>You can see the packages that have been created or revised in
the last month with the <b>ssc new</b> command. 

<pre><blockquote>. ssc new</pre></blockquote>

<p>When I executed this command, approximately 50 commands 
were listed that have been created or updated in the last month. 
This illustrates how lively the activity is with respect to 
updates and new contributions to the ssc archive.</p>

<p>Suppose that, after perusing the output of <b>ssc new</b> 
or <b>ssc hot</b> that you find decide that you want
to install a package, for example the package called
<b>outreg2</b>. You can then simply type

<pre><blockquote>. ssc install outreg2</pre></blockquote>

<p>and that package is downloaded and installed. You can
then begin using the programs described in the program.
You can view the help file by typing

<pre><blockquote>. help outreg2</pre></blockquote>

<p>You can learn more about the SSC archive with the 
<a href="http://www.stata.com/help.cgi?ssc">help ssc</a> command. 
 
<p>You can download the example data files from this tidbit 
(as well as all of the other tidbits) as shown below.
These will download all of the example data files into 
the current folder on your computer. (If you have done this
before, then you may need to specify <b>net get stowdata, replace</b> 
to overwrite the existing files.
<pre><blockquote>net from http://www.MichaelNormanMitchell.com/storage/stowdata
net get stowdata
</pre></blockquote>

If you have thoughts on this Stata Tidbit of the Week, you can 
post a comment. You can also send me an email at MichaelNormanMitchell 
and then the at sign and gmail dot com. 
If you are receiving this tidbit via email, you can find
the web version at 
<a href="http://www.MichaelNormanMitchell.com/">
http://www.michaelnormanmitchell.com/</a> .
</p>]]></content:encoded></rss:item><rss:item rdf:about="http://www.michaelnormanmitchell.com/stow/ssc-help-files-over-the-internet.html"><rss:title>SSC help files over the internet</rss:title><rss:link>http://www.michaelnormanmitchell.com/stow/ssc-help-files-over-the-internet.html</rss:link><dc:creator>Michael Mitchell</dc:creator><dc:date>2011-04-13T03:01:23Z</dc:date><dc:subject></dc:subject><content:encoded><![CDATA[<p>In the tidbit from last week we saw how you can
view Stata help files over the internet. Did you know that
you can view the help files for programs stored 
in the Statistical Software Components (SSC) 
archive as well? (Thanks to Kit Baum for sharing this with me). 
Here are some examples.

<ul>
<li><a href="http://repec.org/help.php?c=somersd">http://repec.org/help.php?c=somersd</a></li>
<li><a href="http://repec.org/help.php?c=texdoc">http://repec.org/help.php?c=texdoc</a></li>
<li><a href="http://repec.org/help.php?c=egenmore">http://repec.org/help.php?c=egenmore</a></li>
</ul>

As you can see from the examples, each begins with <b>http://repec.org/help.php?c</b> 
followed by the name of the program. The name of the program generally (but 
not always) corresponds to the name of the package. 

<p>You can use this as a means of displaying the help file for SSC programs within
your web site or perhaps for sending the link of a help file to a friend.
For more information about the SSC archive, see <a href="http://www.stata.com/help.cgi?ssc">help ssc</a>.

 
<p>You can download the example data files from this tidbit 
(as well as all of the other tidbits) as shown below.
These will download all of the example data files into 
the current folder on your computer. (If you have done this
before, then you may need to specify <b>net get stowdata, replace</b> 
to overwrite the existing files.
<pre><blockquote>net from http://www.MichaelNormanMitchell.com/storage/stowdata
net get stowdata
</pre></blockquote>

If you have thoughts on this Stata Tidbit of the Week, you can 
post a comment. You can also send me an email at MichaelNormanMitchell 
and then the at sign and gmail dot com. 
If you are receiving this tidbit via email, you can find
the web version at 
<a href="http://www.MichaelNormanMitchell.com/">
http://www.michaelnormanmitchell.com/</a> .
</p>]]></content:encoded></rss:item><rss:item rdf:about="http://www.michaelnormanmitchell.com/stow/stata-help-files-over-the-internet.html"><rss:title>Stata help files over the internet</rss:title><rss:link>http://www.michaelnormanmitchell.com/stow/stata-help-files-over-the-internet.html</rss:link><dc:creator>Michael Mitchell</dc:creator><dc:date>2011-04-07T03:26:25Z</dc:date><dc:subject>General</dc:subject><content:encoded><![CDATA[<p>Did you know that the Stata help files are available over the internet? 
Normally, you would type, for example <b>help regress</b> and Stata would
display the help file for the <b>regress</b> command. You can also
point your web browser to <a href="http://www.stata.com/help.cgi?regress">http://www.stata.com/help.cgi?regress</a>
and you can see the help file over the internet. As you can see,
the name of the command followed <b>http://www.stata.com/help.cgi?</b>.</p> 

<p>To display the help associated with <b>regress postestimation</b> you can specify
either <a href="http://www.stata.com/help.cgi?regress postestimation">http://www.stata.com/help.cgi?regress postestimation</a> (with a space) or <a href="http://www.stata.com/help.cgi?regress_postestimation">http://www.stata.com/help.cgi?regress_postestimation</a> (with an underscore). If you specify a term that is not the name of a help file, the web page will give you the opption to view the table of contents of the help files, or to search for the term you specified.</p>

<p>I can think of a few
instances where this can be useful. Maybe you want 
to point to a Stata help file from within one of your web pages. Or, perhaps you
might want to send an email to a friend or colleague (who might not have
Stata) with a link pointing to a particular help file in Stata.</p> 

<p>You can download the example data files from this tidbit 
(as well as all of the other tidbits) as shown below.
These will download all of the example data files into 
the current folder on your computer. (If you have done this
before, then you may need to specify <b>net get stowdata, replace</b> 
to overwrite the existing files.
<pre><blockquote>net from http://www.MichaelNormanMitchell.com/storage/stowdata
net get stowdata
</pre></blockquote>

If you have thoughts on this Stata Tidbit of the Week, you can 
post a comment. You can also send me an email at MichaelNormanMitchell 
and then the at sign and gmail dot com. 
If you are receiving this tidbit via email, you can find
the web version at 
<a href="http://www.MichaelNormanMitchell.com/">
http://www.michaelnormanmitchell.com/</a> .
</p>]]></content:encoded></rss:item><rss:item rdf:about="http://www.michaelnormanmitchell.com/stow/stata-version-112.html"><rss:title>Stata version 11.2</rss:title><rss:link>http://www.michaelnormanmitchell.com/stow/stata-version-112.html</rss:link><dc:creator>Michael Mitchell</dc:creator><dc:date>2011-04-01T03:59:50Z</dc:date><dc:subject></dc:subject><content:encoded><![CDATA[<p>The last tidbit was about how to update Stata, and now it is interesting to note that Stata version 11.2 was made available on March 30, 2011. You can obtain that update using the <b>update</b> command as described in the <a href="updating-tip.html">tidbit from last week</a>. 

<p>For more information about the features in this update, you can type <b>help whatsnew</b> in the Stata command window.

<p>You can download the example data files from this tidbit 
(as well as all of the other tidbits) as shown below.
These will download all of the example data files into 
the current folder on your computer. (If you have done this
before, then you may need to specify <b>net get stowdata, replace</b> 
to overwrite the existing files.
<pre><blockquote>net from http://www.MichaelNormanMitchell.com/storage/stowdata
net get stowdata
</pre></blockquote>

If you have thoughts on this Stata Tidbit of the Week, you can 
post a comment. You can also send me an email at MichaelNormanMitchell 
and then the at sign and gmail dot com. 
If you are receiving this tidbit via email, you can find
the web version at 
<a href="http://www.MichaelNormanMitchell.com/">
http://www.michaelnormanmitchell.com/</a> .
</p>]]></content:encoded></rss:item><rss:item rdf:about="http://www.michaelnormanmitchell.com/stow/updating-tip.html"><rss:title>Updating tip</rss:title><rss:link>http://www.michaelnormanmitchell.com/stow/updating-tip.html</rss:link><dc:creator>Michael Mitchell</dc:creator><dc:date>2011-03-17T04:47:21Z</dc:date><dc:subject>General</dc:subject><content:encoded><![CDATA[<p>At work, a number of new people have been using Stata. That means that I have been installing Stata for a number of folks. Not only does this involve installing Stata, but it also involves updating Stata using the <strong>update</strong> command. At first I was using the <b>update all</b> command. As described in the help file, the <strong>update all</strong> command <em>does the same as <strong>update ado</strong> followed by <strong>update executable</strong> and <strong>update utilities</strong></em>. A couple of times I ran into a glitch, one that pops up from time to time on Statalist. The <strong>update ado</strong> command works, and the <strong>update executable</strong> command downloads the update to the executable, but the final step (of performing the <strong>update swap</strong>) is not completed. (This is usually because the person does not realize that they need to perform the <b>update swap</b> command to complete the updating of the Stata executable.) 

<p>The result is that the <strong>ado</strong> files can be more recent than the executable, and until the executable is updated, some commands will not work because they are newer than the executable. To avoid this, I have started doing the updates in a different order. First, I use the </p>

<pre><blockquote>. update executuable</blockquote></pre>

<p>command to update the Stata executable file. I make sure that the update of the executable, if any, is complete. This can include using the <b>update swap</b> command and restarting Stata. Then, after the executable has been updated, I type 

<pre><blockquote>. update ado</blockquote></pre>

<p>This updates any of the ado files. After that is complete, I then run
the 

<pre><blockquote>. update utilities</blockquote></pre>

<p>command. This updates Stata utilities including the Stata PDF documentation. This last step can take a while if there are many PDF files that need to be updated. However, I can pass the baton at this stage because I know that the executable and ado files have both been updated properly. This takes a bit longer, but ensures that the update is fully successful. For more information, you can see <b>help update</b>.</p>

<p>You can download the example data files from this tidbit 
(as well as all of the other tidbits) as shown below.
These will download all of the example data files into 
the current folder on your computer. (If you have done this
before, then you may need to specify <b>net get stowdata, replace</b> 
to overwrite the existing files.
<pre><blockquote>net from http://www.MichaelNormanMitchell.com/storage/stowdata
net get stowdata
</pre></blockquote>

If you have thoughts on this Stata Tidbit of the Week, you can 
post a comment. You can also send me an email at MichaelNormanMitchell 
and then the at sign and gmail dot com. 
If you are receiving this tidbit via email, you can find
the web version at 
<a href="http://www.MichaelNormanMitchell.com/">
http://www.michaelnormanmitchell.com/</a> .
</p>]]></content:encoded></rss:item><rss:item rdf:about="http://www.michaelnormanmitchell.com/stow/setting-return-messages-on.html"><rss:title>Setting return messages on</rss:title><rss:link>http://www.michaelnormanmitchell.com/stow/setting-return-messages-on.html</rss:link><dc:creator>Michael Mitchell</dc:creator><dc:date>2011-03-04T05:20:37Z</dc:date><dc:subject>General</dc:subject><content:encoded><![CDATA[<!-- Setting return messages on --> 
 
<p>Lately I have been working with some very large
datasets and have been interested in how long 
Stata commands take to complete. 
The <b>set rmsg on</b> command has been useful
for showing how long each command takes to execute,
as well as the time it completed. To turn
on return messages, you can type</p>

<pre><blockquote>. set rmsg on</blockquote></pre>

To illustrate the effect of this command, 
let's use the <b>auto</b> dataset and the run a logistic
regression. </p>

<pre><blockquote>. sysuse auto
(1978 Automobile Data)
r; t=0.00 10:52:02

. logit  foreign gear_ratio displacement turn length weight

Iteration 0:   log likelihood =  -45.03321  
Iteration 1:   log likelihood = -21.846131  
Iteration 2:   log likelihood = -16.826028  
Iteration 3:   log likelihood = -15.938989  
Iteration 4:   log likelihood = -15.883186  
Iteration 5:   log likelihood =  -15.88236  
Iteration 6:   log likelihood =  -15.88236  

Logistic regression                               Number of obs   =         74
                                                  LR chi2(5)      =      58.30
                                                  Prob > chi2     =     0.0000
Log likelihood =  -15.88236                       Pseudo R2       =     0.6473

------------------------------------------------------------------------------
     foreign |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
  gear_ratio |   3.536476   1.799346     1.97   0.049     .0098232    7.063128
displacement |  -.0371318    .033608    -1.10   0.269    -.1030023    .0287388
        turn |  -.5515612    .242733    -2.27   0.023    -1.027309   -.0758133
      length |   .1025261   .0834969     1.23   0.219    -.0611249    .2661771
      weight |  -.0001706   .0027558    -0.06   0.951     -.005572    .0052307
       _cons |  -3.973186   10.60993    -0.37   0.708    -24.76827     16.8219
------------------------------------------------------------------------------
r; t=0.48 10:52:33</blockquote></pre>

<p>Each command ends with a return message that
begins with <b>r;</b> and then shows the 
amount of time it took to execute the command and
when the command completed. The <b>sysuse</b> command
took almost no time at all (less than a tenth of 
a second). The <b>logit</b> command took .48 seconds
and completed at 10:52am. This can be useful
for seeing how long a particular command takes
to complete. This setting will also show how
long a do-file takes to complete (and
the time it completed).</p>

<p>If you want to make this setting permanent,
you can type <b>set rmsg on, permanently</b>
and Stata will remember this setting for
future Stata sessions. 

<p>For more information, you can see <b>help rmsg</b>.</p>

You can download the example data files from this tidbit 
(as well as all of the other tidbits) as shown below.
These will download all of the example data files into 
the current folder on your computer. (If you have done this
before, then you may need to specify <b>net get stowdata, replace</b> 
to overwrite the existing files.
<pre><blockquote>net from http://www.MichaelNormanMitchell.com/storage/stowdata
net get stowdata
</pre></blockquote>

If you have thoughts on this Stata Tidbit of the Week, you can 
post a comment. You can also send me an email at MichaelNormanMitchell 
and then the at sign and gmail dot com. 
If you are receiving this tidbit via email, you can find
the web version at 
<a href="http://www.MichaelNormanMitchell.com/">
http://www.michaelnormanmitchell.com/</a> .
</p>]]></content:encoded></rss:item><rss:item rdf:about="http://www.michaelnormanmitchell.com/stow/command-log-files.html"><rss:title>Command log files</rss:title><rss:link>http://www.michaelnormanmitchell.com/stow/command-log-files.html</rss:link><dc:creator>Michael Mitchell</dc:creator><dc:date>2011-02-24T07:20:14Z</dc:date><dc:subject>General</dc:subject><content:encoded><![CDATA[<p>Did you know that you can create a log file that stores
just your Stata commands? These are called command log files
and can be created using the <b>cmdlog</b> command. 
These kinds of log files can be useful if you want to
save the commands, but not the output, from your
Stata session. This can be useful, for example, if you
are trying out some commands that you will later edit
and combine into a do-file. 

<p>You can begin a command log with the <b>cmdlog</b>
command, for example...

<pre><blockquote>. cmdlog using mycommands</blockquote></pre>

opens up a log file named <b>mycommands.txt</b>. Note
that the extension for command files is <b>.txt</b>, emphasizing
that they are text files.

<p>Now, every command that you type (and just the
commands) will be saved in the file <b>mycommands.txt</b>.</p>

<p>When you want to close the file, you can type the
command.</p>

<pre><blockquote>. cmdlog close</blockquote></pre>

<p>The log then contains all of the commands that you
typed after opening the command log. Here is an
example.

<pre><blockquote>. type mycommands.txt
sysuse auto
describe
summarize</blockquote></pre>

<p>If you exit Stata before closing the command log file, 
Stata will close the file for you. You can have
a command log and a regular log open at the same
time. For more information, see <b>help log</b>.</p>

<p>You can download the example data files from this tidbit
(as well as all of the other tidbits) as shown below.
These will download all of the example data files into
the current folder on your computer. (If you have done this
before, then you may need to specify <b>net get stowdata, replace</b>
to overwrite the existing files.
<pre><blockquote>net from http://www.MichaelNormanMitchell.com/storage/stowdata
net get stowdata
</pre></blockquote>

If you have thoughts on this Stata Tidbit of the Week, you can
post a comment. You can also send me an email at MichaelNormanMitchell
and then the at sign and gmail dot com.
If you are receiving this tidbit via email, you can find
the web version at
<a href="http://www.MichaelNormanMitchell.com/">
http://www.MichaelNormanMitchell.com/</a> .
</p>]]></content:encoded></rss:item><rss:item rdf:about="http://www.michaelnormanmitchell.com/stow/creating-multiple-log-files.html"><rss:title>Creating multiple log files</rss:title><rss:link>http://www.michaelnormanmitchell.com/stow/creating-multiple-log-files.html</rss:link><dc:creator>Michael Mitchell</dc:creator><dc:date>2011-02-16T07:00:26Z</dc:date><dc:subject>General</dc:subject><content:encoded><![CDATA[<p>The tidbit from last week described a started set of commands for
creating a log file from within a do-file. This week we take that
basic structure and augment it with the ability to have more than
one log file open at once. 

<p>To recap from last week, we saw a do-file that looked like the following.

<pre><blockquote>. capture log close
. log using mergefiles, replace

* Some commands here.

. log close</blockquote></pre>

<p>Now, imagine that we wanted to write a do-file that would 
analyze our data. It would include a long set of tabulations, 
a long set crosstabulations, and then a long set of
regressions. Say the do-file was named <b>analyze.do</b>.
The contents of the do-file might look like this.

<pre><blockquote>. capture log close
. log using analyze, replace

* Some commands here.

. log close</blockquote></pre>

<p>But suppose we also wanted to separate the output
into three separate log files, the tabulations, the crosstabs, and
the regressions. We could do so like this.

<pre><blockquote>. capture log close
. log using analyze, replace

capture log close logtab
log using tab, replace name(logtab)
* Tabulation commands here.
log close logtab

capture log close logxtab
log using xtab, replace name(logxtab)
* Cross tabulation commands here.
log close logxtab

capture log close logreg
log using reg, replace name(logreg)
* Regression commands here.
log close logreg

. log close</blockquote></pre>

<p>Running this do-file would create the overall log file
named <b>analyze.smcl</b> that would contain the
commands and output from the entire do-file.
The log file <b>tab.smcl</b> would contain just
the output of the tabulations, <b>xtab.smcl</b>
would contain the output of the cross tabulations,
and <b>reg.smcl</b> would contain the output of
the regression analyses. 

The log file for the tabulations includes
the <b>name(logtab)</b> option that specifies
that the <b>logname</b> is <b>logtab</b>. The
<b>capture log close logtab</b> and <b>log close logtab</b>
commands specifically refer to that log file, letting
Stata know that we are referring to the log file 
with the <b>logname</b> of <b>logtab</b> 

<p>At any one time, this do-file has up to two log files
active at once. You can have up to five SMCL logs and
five text (.log) files active at one time, probably more
than you would ever need. For more information, see <b>help log</b>.

<p>You can download the example data files from this tidbit
(as well as all of the other tidbits) as shown below.
These will download all of the example data files into
the current folder on your computer. (If you have done this
before, then you may need to specify <b>net get stowdata, replace</b>
to overwrite the existing files.
<pre><blockquote>net from http://www.MichaelNormanMitchell.com/storage/stowdata
net get stowdata
</pre></blockquote>

If you have thoughts on this Stata Tidbit of the Week, you can
post a comment. You can also send me an email at MichaelNormanMitchell
and then the at sign and gmail dot com.
If you are receiving this tidbit via email, you can find
the web version at
<a href="http://www.MichaelNormanMitchell.com/">
http://www.MichaelNormanMitchell.com/</a> .
</p>]]></content:encoded></rss:item><rss:item rdf:about="http://www.michaelnormanmitchell.com/stow/log-files-and-do-files.html"><rss:title>log files and do-files</rss:title><rss:link>http://www.michaelnormanmitchell.com/stow/log-files-and-do-files.html</rss:link><dc:creator>Michael Mitchell</dc:creator><dc:date>2011-02-09T07:00:10Z</dc:date><dc:subject>General Programming</dc:subject><content:encoded><![CDATA[<p>The tidbit from last week described the different kinds of Stata log files you
can create, .log files and SMCL files. This tidbit illustrates creating log files
within a a do-file. 

<p>A do-file allows you to simplify the process of repeating a series of Stata 
commands. However, without a log file, you have no permenent record
of the results of running a do-file. This is why I create a log file
as part of almost every do-file that I create. Suppose I create a do-file named
<b>mergefiles.do</b>. It will look something like this.

<pre><blockquote>. log using mergefiles, replace

* Some commands here.

. log close</blockquote></pre>

<p>The first <b>log using</b> command creates a log file with the
name <b>mergefiles.smcl</b> (the same name as the do-file),
and will overwrite it if it already exists. Then, some commands
are executed, followed by the <b>log close</b> command.
The only fly in the ointment is if the do-file encounters an error,
in which case the <b>log close</b> command would not be 
executed, leaving the log file open. When the do-file is
executed again, the <b>log using</b> command will result in
an error, because the log is already open. So, my standard
do-file looks more like the following.

<pre><blockquote>. capture log close
. log using mergefiles, replace

* Some commands here.

. log close</blockquote></pre>

<p>The <b>capture log close</b> command forces the log to be closed,
whether it was open or not. Then, the <b>log using</b> command 
opens the log file, the commands are executed, and the
log file is closed. This is a bare bones outline for a do-file
to make sure you always have a permenent record of running
the do-file. And, if you change the name of the do-file,
be sure to change the name of the log file within the
<b>log using</b> command. For more information, see <b>help log</b>.

<p>Next week I will discuss how to have more than one log
file active at a time.

<p>You can download the example data files from this tidbit
(as well as all of the other tidbits) as shown below.
These will download all of the example data files into
the current folder on your computer. (If you have done this
before, then you may need to specify <b>net get stowdata, replace</b>
to overwrite the existing files.
<pre><blockquote>net from http://www.MichaelNormanMitchell.com/storage/stowdata
net get stowdata
</pre></blockquote>

If you have thoughts on this Stata Tidbit of the Week, you can
post a comment. You can also send me an email at MichaelNormanMitchell
and then the at sign and gmail dot com.
If you are receiving this tidbit via email, you can find
the web version at
<a href="http://www.MichaelNormanMitchell.com/">
http://www.MichaelNormanMitchell.com/</a> .
</p>]]></content:encoded></rss:item></rdf:RDF>
