Error: Not in outer par mode with estwide table

I am new to using TeX. I am trying to call a table as a tex file that is created in Stata 14. I am using estwide command. But I am getting an error message " Not in outer par mode" . I checked the previously posted questions and answers about it, however the changes didn't correct the error. I am attaching my codes and the tex file. Note that I have tex codes for the table that Stata created in tex form. When I copy and paste that tex, there is no error. The table is compiled. However, I am trying to automize adding tables and figures in TeX file. I am using OS X El Capitan v.10.11.4. Any help would be appreciated! I couldn't upload the tex file that I want to add. But it is in the code "comment"ed. Thanks E. Watson

\documentclass[letterpaper,oneside,11pt]{book}

\usepackage{graphicx}
\usepackage{amssymb,amsmath,amsthm}
%\usepackage{bm}
\usepackage[total={6in,9in}, top=1.0in, bottom=1.0in, left=1.25in, right=1.25in, includefoot]{geometry}
\usepackage{url}
\usepackage{ifthen}
\usepackage{setspace}
\usepackage{url}
\usepackage[usenames,dvipsnames]{color}
\usepackage{hyperref}
%\usepackage{longtable}
%\usepackage{lscape}
\usepackage{rotating}
\usepackage{natbib}
\usepackage{cite}
\usepackage{multirow}
%\usepackage{endfloat}
\usepackage{makebox}
\usepackage{caption}
\usepackage{subfig}
\usepackage{fancyhdr}
\usepackage{geometry}
\usepackage{bbm}
\usepackage{setspace}
\usepackage{natbib}
\usepackage{amsmath}
\usepackage{cite}
\usepackage{rotating}
\usepackage{tabularx}
\usepackage{array}
\usepackage{microtype}
\usepackage{indentfirst}
\usepackage{booktabs}
\usepackage{float}

%\renewcommand{\thetable}{\Roman{table}}
\graphicspath{{png/}}
\newcommand{\comment}[1]{}
\setcounter{MaxMatrixCols}{10}

% Alter some LaTeX defaults for better treatment of figures:
% See p.105 of "TeX Unbound" for suggested values.
% See pp. 199-200 of Lamport's "LaTeX" book for details.
%   General parameters, for ALL pages:
\renewcommand{\topfraction}{0.9}    % max fraction of floats at top
\renewcommand{\bottomfraction}{0.8} % max fraction of floats at bottom
%   Parameters for TEXT pages (not float pages):
\setcounter{topnumber}{2}
\setcounter{bottomnumber}{2}
\setcounter{totalnumber}{4}     % 2 may work better
\setcounter{dbltopnumber}{2}    % for 2-column pages
\renewcommand{\dbltopfraction}{0.9} % fit big float above 2-col. text
\renewcommand{\textfraction}{0.07}  % allow minimal text w. figs
%   Parameters for FLOAT pages (not text pages):
\renewcommand{\floatpagefraction}{0.7}  % require fuller float pages
% N.B.: floatpagefraction MUST be less than topfraction !!
\renewcommand{\dblfloatpagefraction}{0.7}   % require fuller float pages

\pagestyle{empty}
%\input{math.tex}
%\input{include.tex}
\newboolean{issolution}
\setboolean{issolution}{false}
\newboolean{isdraft}
\setboolean{isdraft}{true}
%\input{tcilatex}

%%%%%% NEW PRE %%%%%
% Packages for tables
\usepackage{booktabs}% Pretty tables
\usepackage{threeparttablex}% For Notes below table

% *****************************************************************
% siunitx
% *****************************************************************
\newcommand{\sym}[1]{\rlap{#1}} % Thanks to Joseph Wright & David Carlisle

\usepackage{siunitx}
\sisetup{
detect-mode,
group-digits            = false,
input-symbols           = ( ) [ ] - +,
table-align-text-post   = false,
input-signs             = ,
}

% Character substitution that prints brackets and the minus symbol in text mode. Thanks to David Carlisle
\def\yyy{%
\bgroup\uccode\~\expandafter\string-%
\uppercase{\egroup\edef~{\noexpand\text{\llap{\textendash}\relax}}}%
\mathcode\expandafter\string-"8000 }

\def\xxxl#1{%
\bgroup\uccode\~\expandafter\string#1%
\uppercase{\egroup\edef~{\noexpand\text{\noexpand\llap{\string#1}}}}%
\mathcode\expandafter\string#1"8000 }

\def\xxxr#1{%
\bgroup\uccode\~\expandafter\string#1%
\uppercase{\egroup\edef~{\noexpand\text{\noexpand\rlap{\string#1}}}}%
\mathcode\expandafter\string#1"8000 }

\def\textsymbols{\xxxl[\xxxr]\xxxl(\xxxr)\yyy}

% *****************************************************************
% Estout related things
% *****************************************************************
\let\estinput=\input % define a new input command so that we can still flatten the document

\newcommand{\estwide}[3]{
\vspace{.75ex}{
\textsymbols% Note the added command here
\begin{tabular*}
{\textwidth}{@{\hskip\tabcolsep\extracolsep\fill}l*{#2}{#3}}
\toprule
\estinput{#1}
\bottomrule
\end{tabular*}
}
}

\newcommand{\estauto}[3]{
\vspace{.75ex}{
\textsymbols% Note the added command here
\begin{tabular}{l*{#2}{#3}}
\toprule
\estinput{#1}
\bottomrule
\end{tabular}
}
}

% Allow line breaks with \\ in specialcells
\newcommand{\specialcell}[2][c]{%
\begin{tabular}[#1]{@{}c@{}}#2\end{tabular}
}

% *****************************************************************
% Custom subcaptions
% *****************************************************************
% Note/Source/Text after Tables
% The new approach using threeparttables to generate notes that are the exact width of the table.
\newcommand{\Figtext}[1]{%
\begin{tablenotes}[para,flushleft]
\hspace{6pt}
\hangindent=1.75em
#1
\end{tablenotes}
}
\newcommand{\Fignote}[1]{\Figtext{\emph{Note:~}~#1}}
\newcommand{\Figsource}[1]{\Figtext{\emph{Source:~}~#1}}
\newcommand{\Starnote}{\Figtext{* p < 0.1, ** p < 0.05, *** p < 0.01. Standard errors in parentheses.}}% Add significance note with \starnote

\begin{document}

\doublespacing
\section{Appendix}
%%%%%% TABLES %%%%%

\begin{table}
\centering
\begin{threeparttable}
\caption{Table1}
\estwide{/Users/Shared/Example/table1.tex}{2}{c}
\end{threeparttable}
\end{table}

%%% This part pasted from tex file stata created.
%%  It compiles without error.
%\begin{table}[htbp]\centering
%\caption{Regression table\label{tab1}}
%\begin{tabular}{l*{2}{c}}
%\hline\hline
%                    &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}\\
%                    &\multicolumn{1}{c}{Price}&\multicolumn{1}{c}{Price}\\
%\hline
%Weight (lbs.)       &       1.747&       3.465\\
%                    &      (2.72)&      (5.49)\\
%[1em]
%Mileage (mpg)       &      -49.51&       21.85\\
%                    &     (-0.57)&      (0.29)\\
%[1em]
%Car type            &            &      3673.1\\
%                    &            &      (5.37)\\
%[1em]
%Constant            &      1946.1&     -5853.7\\
%                    &      (0.54)&     (-1.73)\\
%\hline
%Observations        &          74&          74\\
%\hline\hline
%\multicolumn{3}{l}{\footnotesize \textit{t} statistics in parentheses}\\
%\end{tabular}
%\end{table}

\end{document}

• really you should clean up your preamble! you load several packages multiple times (they don't load the second time but it makes the file hard to debug) at least these are loaded more than once: amsmath, geometry, natbib, rotating, cite , setspace – David Carlisle Mar 14 '17 at 11:06
• unrelated to the error but \renewcommand{\floatpagefraction}{0.7} % require fuller float pages makes it highly likely that all floats go to the end of the document – David Carlisle Mar 14 '17 at 11:07
• Thank you! Since I am new and I decided to type up my thesis with TeX, I rushed to copy and paste a thesis preample. I did clean them up, and I will do more after I figure out whether it affects the formatting of the thesis template. – E. Watson Mar 14 '17 at 11:19
• It's a really bad idea to include packages that you don't use. I'd start out by removing them all and just put back ones that you are actually using. – David Carlisle Mar 14 '17 at 11:50

Not in outer par mode means you have a table environment nested inside something that doesn't allow tables. Here it is another table environment.

\begin{table}[htbp]\centering
\caption{Regression table\label{tab1}}


so it is already a complete table float with a caption, not just the table itself.

But you are trying to input it as

\begin{table}
\centering
\begin{threeparttable}
\caption{Table1}
\estwide{/Users/Shared/Example/table1.tex}{2}{c}
\end{threeparttable}
\end{table}


so putting a table inside a threeparttable inside a table. That can not work, just use

\input{table1.tex}


or (if that's possible) get your application to just write the inner tabular to the table1.tex file not wrap it in table and \caption`