Download Learning Stata

Transcript
5.2. ADVANCED TABLES
49
OMG! It included “Table: #” as a first line of the table! Your excitement is premature. The # sign is the placeholder mark. We want to replace it with the
actual title of the table. We can pass this on via the topstr() option, inserting the title of the table between the parentheses (without quotes, mind you).
Stata then replaces the # with it. Assuming our table is called “Prepare to Be
Amazed”, the command is now
tabout stime died using table.txt, replace
///
cells(freq col cum) format(0 1 1) clab(No. Col_% Cum_%) ///
topf(top.txt) topstr(Prepare to Be Amazed)
I am amazed. Insert a footer using botf(), botstr() and bottom.txt in much
the same way.
To illustrate one last cool functionality of tabout, add the following note
to stime: “Calculated in some complex and ridiculous fashion”. I will now add
this note, as well as a line mentioning the data source, at the bottom of the
table.
You’ve added the note, right? Recall how to list all notes stored in Stata’s
memory? Use the char list command. Locate the note we added for stime.
It’s near the bottom. Jot down the name associated to that note: stime[note1].
Great.
We’ll now pass the text of stime[note1] into the footer of our table. But,
first, we have to set up the bottom.txt file to handle it. So open it up in a text
editor, and add
Data notes: #
at the top of the file. Save and close it. Next, include the botf() option,. What
should go between the parentheses?
botstr(`stime[note1]')
This tells Stata to pass on the contents of stime[note1] to bottom.txt. bottom.txt then uses it to replace #. Let’s give it a go:
tabout stime died using table.txt, replace
///
cells(freq col cum) format(0 1 1) clab(No. Col_% Cum_%) ///
topf(top.txt) topstr(Prepare to Be Amazed)
///
botf(bottom.txt) botstr(`stime[note1]')
Why did I precede stime[note1] with front and and back ticks? I’m glad
you asked. This is something called a local macro, which we haven’t talked
about yet, but we will very shortly (Section 8.1). Anyway, all variable and
value labels are stored in as local macros, and enclosing them with ticks
signals to Stata what what they are.