Writing Complex Tables in Stata

Over at scatterplot, I asked for help with Stata code for automating descriptive tables. I did not fully solve the problem, but I am posting here a sample of the code that worked because when I searched for help, all I could find was partial syntax outlines that did not give enough information to help me avoid pitfalls. The particular feature of this problem is that it is non-standard: each row/column is a different subset of the data, not different variables or different statistics on the same variable, and each table is a different subset of the data. This code puts each table on a separate page (page breaks between them). Word or WordPerfect can parse the output tables and can turn them into tables with the “convert text to table” option available in both programs. (For some reason, however, Excel did not properly parse the page breaks, viewing them as unrecognized characters.  In any event, a spreadsheet is less desireable as a target for this application because spreadsheets treat all columns the same, and in this application there are different numbers of solumns and the columns have different widths in each table.) I have not successfully generated a macro in the word processor to mark and convert the tables — my attempts to do this with “record macro” in both word processors were unsuccessful because the recorded macro did not work the way the program worked during recording.  If you know how to write a Word or WordPerfect macro that will select a block of comma-deliimited text with varying numbers of rows and columns and convert it to a table with the option to resize columns to fit contents and then right-justify the columns (or, better, right-justify the right-most n of the columns while left-justifying the leftmost m of the columns), please drop a comment here.  (For you techies out there, I’ll tell you that LaTeX does not appear to be a particularly good solution for this kind of problem because LaTeX does not automatically wrap text in a table unless you pre-specify how wide you want the columns to be. Of course, there may be an add-on out there somewhere that would do it.)  Below  is a condensed version of the code that worked to generate the tables: Continue reading “Writing Complex Tables in Stata”

graphs on the web

I recently asked for advice about the best format for posting a lot of graphs on a web site so they could be either read on line or downloaded and printed.  In case this information is more generally useful, I’m summarizing what I learned here.  Continue reading “graphs on the web”