[Tex/LaTex] Landscape with longtable

booktabslandscapelongtable

enter image description here

I am trying to construct a table with longscape, like the one shown in the image (with columns defined a bit differently), but I seem to have done something wrong with the code. Any help is appreciated!

\documentclass{article}
\usepackage[margin=0.5in,a4paper]{geometry}

\usepackage{longtable}
\usepackage{array,booktabs, makecell, multirow}
\renewcommand\theadfont{\bfseries\small}
\newcommand\mcseven[1]{\multicolumn{7}{l}{#1}}
\usepackage{arydshln}
\setlength\dashlinedash{0.2pt}
\setlength\dashlinegap{1.5pt}
\setlength\arrayrulewidth{0.3pt}
\usepackage{pdflscape}
\usepackage{afterpage}

%Widows & Orphans & Penalties

\widowpenalty500
\clubpenalty500
\clubpenalty=9996
\exhyphenpenalty=50 %for line-breaking at an explicit hyphen
\brokenpenalty=4991
\predisplaypenalty=10000
\postdisplaypenalty=1549
\displaywidowpenalty=1602
\floatingpenalty = 20000
\usepackage{siunitx}

\begin{document}
 \afterpage{\clearpage}
\thispagestyle{empty}
\begin{landscape}
    \centering
\begin{longtable}[ht]{ l*{7}{S[table-format=2.3]}}
\caption{OLS results}
\label{tab:OLS1}                                                             \\
\toprule
\thead[b]{Dependent variable\\ log hourly wages}               \\
 \multicolumn{2}{c}{Male}
        & \multicolumn{2}{c}{Female}
            &  \multicolumn{2}{c}{Pooled}
\cmidrule(lr){1-1}\cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}
    & {coeff} & {SE} & {coeff} & {SE} & {coeff} & {SE}       \\
\hdashline                                                               \\
\endfirsthead

%%%%
\caption{OLS results}                 \\
\toprule
\thead[b]{Dependent variable\\ log hourly wages}               \\
 &  \multicolumn{2}{c}{Male}
        & \multicolumn{2}{c}{Female}
            &  \multicolumn{2}{c}{Pooled}
 \cmidrule(lr){1-1)\cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}
    & {coeff} & {SE} & {coeff} & {SE} & {coeff} & {SE}       \\
    \midrule                                                                \\
\endhead
\midrule
\multicolumn{7}{r}{\footnotesize\textit{Continue on the next page}}
\endfoot
\endlastfoot

Panel A: 2010-11 \\
{Constant} & 2.162624 & 0.0623814 & 1.847009 & 0.2195808 & 1.891113 & 0.0616229 \\
{Experience} & 0.0293973 & 0.0018267 & 0.0436007 & 0.0044678 & 0.0337108 & 0.0017411 \\
{Experience Square} & -0.0003169 & 0.0000336 & -0.0004819 & 0.0000801 & -0.0003634 & 0.0000319 \\
%further rows omitted 
 \bottomrule
\end{longtable}

\end{landscape}  

\end{document}

Best Answer

I suppose it's something like this you want. The numbers format did not correspond to you actual numbers: 2.3 means 2 digits before the decimal dot and 3 decimal digits. You have 1 before the dot (and sometimes a minus sign) and 6 or 7 after:

\documentclass{article}
\usepackage[margin=0.5in, a4paper]{geometry}

\usepackage{longtable}
\usepackage{array,booktabs, makecell, multirow}
\renewcommand\theadfont{\bfseries\small}
\newcommand\mcseven[1]{\multicolumn{7}{l}{#1}}
\usepackage{arydshln}
\setlength\dashlinedash{0.2pt}
\setlength\dashlinegap{1.5pt}
\setlength\arrayrulewidth{0.3pt}
\usepackage{pdflscape}
\usepackage{afterpage}

%Widows & Orphans & Penalties

\widowpenalty500
\clubpenalty500
\clubpenalty=9996
\exhyphenpenalty=50 %for line-breaking at an explicit hyphen
\brokenpenalty=4991
\predisplaypenalty=10000
\postdisplaypenalty=1549
\displaywidowpenalty=1602
\floatingpenalty = 20000
\usepackage{siunitx}

\begin{document}

\afterpage{\clearpage}
\thispagestyle{empty}
\begin{landscape}
  \centering
  \begin{longtable}{ l*{7}{S[table-format=-1.7, table-alignment=center]}}
    \caption{OLS results}
    \label{tab:OLS1} \\
    \toprule
    \thead[b]{Dependent variable \\ log hourly wages}
                        & \multicolumn{2}{c}{Male}
                        & \multicolumn{2}{c}{Female}
                        & \multicolumn{2}{c}{Pooled} \\
    \cmidrule(lr){1-1}\cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}
                        & {coeff} & {SE} & {coeff} & {SE} & {coeff} & {SE} \\
    \hdashline \\
    \endfirsthead

    %%%%
    \caption{OLS results} \\
    \toprule
    \thead[b]{Dependent variable \\ log hourly wages} \\
                        & \multicolumn{2}{c}{Male}
                        & \multicolumn{2}{c}{Female}
                        & \multicolumn{2}{c}{Pooled} \\
    \cmidrule(lr){1-1}\cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}
                        & {coeff} & {SE} & {coeff} & {SE} & {coeff} & {SE} \\
    \midrule \\
    \endhead
    \midrule
    \multicolumn{7}{r}{\footnotesize\textit{Continue on the next page}}
    \endfoot
    \bottomrule
    \endlastfoot
    Panel A: 2010-11 \\
    {Constant} & 2.162624 & 0.0623814 & 1.847009 & 0.2195808 & 1.891113 & 0.0616229 \\
    {Experience} & 0.0293973 & 0.0018267 & 0.0436007 & 0.0044678 & 0.0337108 & 0.0017411 \\
    {Experience Square} & -0.0003169 & 0.0000336 & -0.0004819 & 0.0000801 & -0.0003634 & 0.0000319
    %further rows omitted
  \end{longtable}
\end{landscape}

\end{document} 

enter image description here