Producing survey “tabs” in Stata: PolMeth question answered

Thanks to those participants in the Political Methodology listserv who responded to a query that I posted a month ago about how to produce survey “toplines” using either Stata or R. The attached document provides a detailed summary of the responses; I have posted the most useful reply here.

Original Question

From: Paul Gronke <>

Quick question for the list: Lisa Bryant (CU Fresno) and I are preparing  some “top lines” and “tabs” for a client with whom we conducted a survey.

If you have seen these before, they are usually organized so that  categorial survey responses are reported on the rows, and the columns  report the overall responses, then responses “tabbed” or “crossed” by  various demographic and political categories. Roll your eyes if you will  that this is just a big set of exploratory cross tabs, but a lot of folks  expect to see them to help digest the survey results.

A typical “tab” looks like this:

VARIABLE                        Total   GOP     IND             DEM MEN     WOMEN    …

Category 1                             N  %    N  %    N  %            N  %    N %    N  %

Category 2                      N  % …


Stata Special

From: Jonathan Mendelson

Hi Paul,

I posted a response to the list, but it hasn’t gone through yet, so I thought I’d reply directly.  I encountered the same issue as you and wrote a Stata package that essentially creates “tabs” in spreadsheet form.  You can install it in Stata via “ssc install tabsheet” or view information at; there are examples in the documentation so you should be able to get started fairly quickly.

The program is not particularly flexible, but it is easy to use, and some colleagues at my survey firm have found it very useful.  Although it doesn’t currently output to anything other than tab-delimited file (which can be opened in a spreadsheet), with some clever formatting in Excel, you could print the resulting spreadsheet to PDF for something nicer looking.

If you need something more flexible in Stata, I’d recommend tabout, although that may require more work to set up.  If you find out about any R packages that do something similar, I’d be interested in hearing about it.


The complete list of responses, including various R and Stata solutions, is provided in this PDF: polmeth-question-survey-tabs