2

I am using stata 12. I have a very long frequency table that I need to put in the appendix (it's composed of countries), I would like to have this table in one single page as opposed to a very long table for output in LaTeX.

That is, instead of having something like this (I omit the \table and \tabular environments and go strictly to the column problem):

    Country &  Frequency\\
    \textbf{U.S.} & 4\\
    \text{bf{U.K.} & 10\\
    \textbf{Uganda} & 7\\
    \textbf{Uzbekistan} & 2\\

...

to something like this:

    Country & Frequency & Country & Frequency & Country & Frequency & Country & Frequency\\
   \textbf{U.S.} & 4 & \text{bf{U.K.} & 10 & \textbf{Uganda} & 7 & \textbf{Uzbekistan} & 2\\

...

This would be much more economical on paper.

1

1 Answer 1

3

You can use pgfplotstable to separate the data and the table format

\documentclass{article}
\usepackage{pgfplotstable,booktabs}
% Just make a table of things
% It doesn't have to be in the preamble
% but just to show the idea, it's moved to here
\pgfplotstableread[col sep=comma]{
country, freq
Afghanistan            ,AF      
Aland Islands          ,AX      
Albania                ,AL      
Algeria                ,DZ      
American Samoa         ,AS      
Andorra                ,AD      
Angola                 ,AO      
Anguilla               ,AI      
Antigua and Barbuda    ,AG      
Argentina              ,AR      
Armenia                ,AM      
Aruba                  ,AW      
Australia              ,AU      
Austria                ,AT      
Azerbaijan             ,AZ      
Bahrain                ,BH      
Bangladesh             ,BD      
Barbados               ,BB      
Belarus                ,BY      
Belgium                ,BE      
Belize                 ,BZ      
Benin                  ,BJ      
Bermuda                ,BM      
Bhutan                 ,BT      
Bolivia                ,BO      
Bosnia and Herzegovina ,BA      
Botswana               ,BW      
Brazil                 ,BR      
}\mycountryfreqtable
% Now the data is in the \mycountryfreqtable
% in the form of pgfplotstable format


\begin{document}

% This starts typesetting the table
\pgfplotstabletypeset[% Put some settings about the rules etc.
every head row/.style={before row=\toprule,after row=\midrule},
every last row/.style={after row=\bottomrule},
% Now insert as many column pairs as you want
% I want 3 groups of columns so repeated thrice
columns={country,freq,country,freq,country,freq},
% Then notice that index starts from zero and I want three parts
% so the command goes 0 of 3, 1 of 3 and 2 of 3
% You don't need to understand right away why 
% just copy paste it. 
display columns/0/.style={select equal part entry of={0}{3},string type},% first part of ‘A’
display columns/1/.style={select equal part entry of={0}{3},string type},% first part of ‘B’
display columns/2/.style={select equal part entry of={1}{3},string type},% second part of ‘A’
display columns/3/.style={select equal part entry of={1}{3},string type},% second part of ‘B’
display columns/4/.style={select equal part entry of={2}{3},string type},% first part of ‘A’
display columns/5/.style={select equal part entry of={2}{3},string type},% first part of ‘B’
]% End of options
{\mycountryfreqtable}


\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .