Stata - Esttab to Latex Decimal Alignment - latex

I am trying to output a LaTex file using Stata's esttab command. I cannot get the decimals to align, nor can I get the nice formatting from the "booktabs" option to work. I also would like to increase the width of the columns. I have been tinkering with this for hours and have had no luck. Below is my Stata code and the LaTex code that I am running through Overleaf. Any help would be greatly appreciated!
Here is my Stata code:
#delimit ;
esttab r1 r2 r3 r4 using "C:\Users\user\Dropbox\Private
Code\Code\STATA\latex\table1.tex", replace
b(3) nomtitle label star(* 0.10 ** 0.05 *** 0.01)
booktabs alignment(D{.}{.}{-1})
title(Placeholder)
s(N DAY FFE FIRM_QUARTER r2_a,
fmt(%9.0fc 0 0 0 3)
label("Observations" "Day FE" "Firm FE" "Firm-Quarter FE" "Adj. R-Sq{\super 2}"))
compress nocons;
Here is the LaTex code it spits out:
\begin{table}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Placeholder}
\begin{tabular}{l*{4}{D{.}{.}{-1}}}
\toprule
&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}
{c}{(3)} &\multicolumn{1}{c}{(4)} \\
\midrule
VAR1 & 0.007\sym{***}& 0.007\sym{***}& 0.006\sym{***}& 0.007\sym{***}\\
& (8.55) & (7.82) & (7.67) & (8.54) \\
\addlinespace
VAR2 & 0.132\sym{***}& 0.131\sym{***}& 0.131\sym{***}& 0.132\sym{***}\\
& (20.35) & (20.15) & (20.15) & (20.35) \\
\midrule
Observations &1,315,077 &1,315,077 &1,315,077 &1,315,077
\\
Day FE & No & Yes & Yes & No \\
Firm FE & Yes & No & Yes & No \\
Firm-Quarter FE & No & No & No & Yes \\
Adj. R-Sq{\super 2}& 0.045 & 0.027 & 0.046 & 0.044
\\
\bottomrule
\multicolumn{5}{l}{\footnotesize \textit{t} statistics in parentheses}\\
\multicolumn{5}{l}{\footnotesize \sym{*} \(p<0.10\), \sym{**} \(p<0.05\), \sym{***} \(
p<0.01\)}\\
\end{tabular}
\end{table}

Since you haven't provided the full code, I can't see what would your output be. When I add \documentclass{article} with missing packages in a preamble, I get very wide table which does not fit a page. Also, I don't know whether the code is automatically generated or created/altered by you.
Assuming the latter, I would do the following. Since you add footnotes in the table, I would enclose tabular within threeparttable, which splits the area for table into three parts: top for captions, middle for a table definition e.g. tabular, and bottom part for footnotes. It also adds a convenient macro \tnote{}.
Secondly, dcolumn causes big numbers to be pushed way too much to the left. You should let dcolumn suppress their alignment. I personally don't know how, although I assume there is a way.
I prefer siunitx for formatting numbers in tables. However siunitx needs a bit more work. It automatically parses numbers in cells and any non-number content generates errors. Therefore, non-numbers need to be enclosed within {...} which instructs siunitx to leave the content intact. It also forces numbers not to be formatted, aligned etc., which is what I did for the big numbers you have in the table. There's also option to format thousands and millions with any separator of your choice. For instance you could use one of the macros: \,, :, or \; for thin, mid or thick space, respectively instead of ,.
Below is my suggestion for your table based on siunitx and threeparttable, so you can compare it with your approach.
\documentclass{article}
\usepackage{array}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{threeparttable}
\newcommand\super[1]{\textsuperscript{#1}}
\sisetup{
group-separator={,},
table-format=1.3,
table-align-text-after = false,
}
\begin{document}
\begin{table}[htbp]
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\centering
\begin{threeparttable}
\caption{Placeholder}
\begin{tabular}{l *{4}{S}}
\toprule
& \multicolumn{1}{c}{(1)}
& \multicolumn{1}{c}{(2)}
& \multicolumn{1}{c}{(3)}
& \multicolumn{1}{c}{(4)} \\
\midrule
{VAR1} & 0.007\tnote{***} & 0.007\tnote{***} & 0.006\tnote{***} & 0.007\tnote{***} \\
& {(8.55)} & {(7.82)} & {(7.67)} & {(8.54)} \\
\addlinespace
VAR2 & 0.132\tnote{***} & 0.131\tnote{***} & 0.131\tnote{***} & 0.132\tnote{***} \\
& {(20.35)} & {(20.15)} & {(20.15)} & {(20.35)} \\
\midrule
Observations
& \multicolumn{1}{c}{\num{1315077}}
& \multicolumn{1}{c}{\num{1315077}}
& \multicolumn{1}{c}{\num{1315077}}
& \multicolumn{1}{c}{\num{1315077}} \\
Day FE & {No} & {Yes} & {Yes} & {No} \\
Firm FE & {Yes} & {No} & {Yes} & {No} \\
Firm-Quarter FE & {No} & {No} & {No} & {Yes} \\
Adj. R-Sq{\super2} & 0.045 & 0.027 & 0.046 & 0.044 \\
\bottomrule
\end{tabular}
\par\(t\) statistics in parentheses
\par\tnote{*} \(p < 0.10\),\quad\tnote{**} \(p < 0.05\),\quad\tnote{***} \(p < 0.01\)
\end{threeparttable}
\end{table}
\end{document}
EDIT. I also enclosed statistics in{...} because siunitx does not recognised brackets as part of a number.

Related

The font size of tables is way too small in Latex

I am generating tables in latex. But the text's font is way too small compared to the main text size, which is 12 pt.
Here is the Latex code
\begin{table}[htp]
\renewcommand{\arraystretch}{2}
\large
\resizebox{1\textwidth}{!}{%
\begin{tabular}{|c|c|c|c|c|c|}
\hline
\textbf{Air pollutant} & \textbf{Detection limit} & \textbf{Concentration range to expect
by EPA} & \textbf{Concentration range in Bristol, UK} & \textbf{Range in Bristol, UK} \\[3ex]
\hline
\textbf{Ozone (O$_{3}$) } & \textbf{10 ppb} & \textbf{0--150 ppb }
& \textbf{0--100 ppb} & \\[3ex] \hline
\textbf{Nitrogen dioxide} & \textbf{10 ppb} & \textbf{0--50 ppb}
& \textbf{20--55 ppb} & \\[3ex] \hline
\textbf{PM$_{2.5}$} & \textbf{5 } & \textbf{0--40 \SI{}
{\micro\gram/m^3}} & \textbf{0--40 \SI{}{\micro\gram/m^3} }
& \\[3ex] \hline
\textbf{PM$_{10}$} & \textbf{10} & \textbf{0--100 \SI{}
{\micro\gram/m^3} } & \textbf{0--100 \SI{}{\micro\gram/m^3}}
& \\[3ex] \hline
\textbf{Temperature range} & ----- & ------ & ----
-- & \textbf{3--$ 21 ^\circ C $} \\[3ex]
\hline
\textbf{Humidity } & ----- & ----- & -----
-- & \textbf{50\%--75\% } \\[3ex] \hline
\end{tabular}%
}
\end{table}
and here is a screenshot of part of PDF to compare the main text and table font
I have this issue for several tables, so any help would be greatly appreciated.
Can I suggest a few things?
You should avoid long headings with narrow content like numbers, unless cells contain long paragraphs, as well. Find the way to shorten the headings, e.g. by adding line breaks.
Repeated content can be grouped and move to separate cells, which can also help with excessive widths.
As you load siunitx, I would recommend to use \qtyrange{}{}{}. Typing them takes the same space and time but in case you need to make changes e.g. you have to change a range marker from -- to to you will appreciate to only have to do it in one place via siunitx. If you repeat long units, it is also possible to define your own units, for the same reason to make changes in one place. I think \SI{}{} is deprecated and should be changed to qty{}{}, although I am not entirely sure about it.
This is my personal taste but IMO tables can look much better without vertical bars. I also added booktabs for improved horizontal rules.
Here's a different version of your table
and the code
\documentclass{article}
\usepackage{array}
\usepackage{siunitx}
\usepackage{multirow}
\usepackage{makecell}
\usepackage{rotating}
\usepackage{booktabs}
\sisetup{
range-units=single,
range-phrase={\,--\,},
}
\DeclareSIUnit\ppb{ppb}
\newcommand\nullval{---}
\renewcommand\theadfont{\normalfont\bfseries}
\renewcommand\theadgape{\Gape[0pt][0pt]}
\begin{document}
\begin{sidewaystable}
\renewcommand\arraystretch{1.2}
\caption{Caption of the table}
\label{tab:table}
\centering
\begin{tabular}{
wc{4cm}
wc{2cm} #{\hspace{1em}}
*3{wc{3cm}}
wc{2cm}
}
\toprule
\multirow{3}*{\thead*{Air\\pollutant}}
& \multirow{3}*{\thead{Detection\\limit}}
& \multicolumn{2}{c}{\thead{Concentration range:}}
& \multirow{3}*{\thead{Range\\in Bristol, UK}} \\
\cmidrule(lr){3-4}
& & \thead{to expect\\by EPA} & \thead{in Bristol\\UK} & \\
\midrule
\thead{Ozone (O\textsubscript{3})}
& \qty{10}{\ppb} & \qtyrange{0}{150}{\ppb} & \qtyrange{0}{100}{\ppb} & \nullval \\
\thead{Nitrogen dioxide}
& \qty{10}{\ppb} & \qtyrange{0}{50}{\ppb} & \qtyrange{20}{55}{\ppb} & \nullval \\
\thead{PM\textsubscript{2.5}}
& 5 & \qtyrange{0}{40}{\mg/m^3} & \qtyrange{0}{40}{\ug/m^3} & \nullval \\
\thead{PM\textsubscript{10}}
& 10 & \qtyrange{0}{100}{\ug/m^3} & \qtyrange{0}{100}{\ug/m^3} & \nullval \\
\thead{Temperature range}
& \nullval & \nullval & \nullval & \qtyrange{3}{21}{\degreeCelsius} \\
\thead{Humidity}
& \nullval & \nullval & \nullval & \qtyrange{50}{75}{\%} \\
\bottomrule
\end{tabular}
\end{sidewaystable}
\end{document}
You should never use \resizebox for elements which contain text.
Instead you could save some space by using multiple lines for your header cells and restructure your table a bit:
\documentclass[12pt]{article}
\usepackage[text-series-to-math=true]{siunitx}
\usepackage{tabularray}
\usepackage{geometry}
\begin{document}
\begin{table}[htp]
\caption{... The temperature range in Bristol, UK was 3--\SI{21}{\degree C} and the humidity 50\%--75\% during the measurement.}
\begin{tblr}{
colspec={XXXXX},
columns={halign=c,valign=m},
row{1}={font=\bfseries},
column{1}={font=\bfseries},
stretch=0,
rows={ht=2\baselineskip},
hlines,
vlines
}
Air pollutant & Detection limit & Concentration range to expect
by EPA & Concentration range in Bristol, UK \\
Ozone (O\textsubscript{3}) & 10 ppb & 0--150 ppb & 0--100 ppb \\
Nitrogen dioxide & 10 ppb & 0--50 ppb & 20--55 ppb \\
PM\textsubscript{2.5} & 5 & 0--40 \SI{}{\micro\gram/m^3} & 0--40 \SI{}{\micro\gram/m^3} \\
PM\textsubscript{10} & 10 & 0--100 \SI{}{\micro\gram/m^3} & 0--100 \SI{}{\micro\gram/m^3} \\
\end{tblr}%
\end{table}
\end{document}

How to insert a picture into a table, spanning multiple rows in latex?

I'm trying to create a table in Latex for a risk assessment for a project. Currently I have the table itself, however I want to insert a picture in the empty white space, spanning multiple rows. When we insert the picture at the moment, it however wont span the rows, and will leave a large white space beneath the illustraion. How can I change it so the illustration does not do so?
The code for the table is as the following:
\usepackage{multirow}
\usepackage[table,xcdraw]{xcolor}
\usepackage{graphicx}
\begin{table}[]
\centering
\begin{tabular}{|ccccc|}
\hline
\rowcolor[HTML]{FFCC67}
\multicolumn{3}{|l|}{\cellcolor[HTML]{FFCC67}{\color[HTML]{000000} Hazard identification}} & \multicolumn{1}{r|}{\cellcolor[HTML]{FFCC67}{\color[HTML]{000000} Hazard nr.}} & {\color[HTML]{000000} 1} \\ \hline
\multicolumn{1}{|l|}{Title} & \multicolumn{2}{l|}{Part picking} & \multicolumn{2}{l|}{} \\ \cline{1-3}
\multicolumn{1}{|l}|}{Taget} & \multicolumn{2}{l|}{Hand} & \multicolumn{2}{l|}{} \\ \cline{1-3}
\multicolumn{1}{|l|}{Activity} & \multicolumn{2}{l|}{Normal operation} & \multicolumn{2}{l|}{} \\ \cline{1-3}
\multicolumn{1}{|l|}{Task} & \multicolumn{2}{l|}{Part gasping} & \multicolumn{2}{l|}{} \\ \cline{1-3}
\multicolumn{1}{|l|}{Hazard Type} & \multicolumn{2}{l|}{Hand crushing} & \multicolumn{2}{l|}{} \\ \hline
\multicolumn{1}{|l|}{Description} & \multicolumn{4}{p{12cm}|}{To get the robot manipulator to pick up the torsion spring it has to travel to at location of the coil of the spring there it shall go down and insert the end-effector into the coil of the spring. There is a possibility that the human operator could have there hand on top of the coil then the robot has to insert the end-effector, the hand could be crouched between the end-effector and the coil. The robot will drive with the speed XX $mm/s$ and the robots torque sensor has the limits of XX $N$. The area of impact is the bottom of the end-effector there is XX $cm^2$. The force limit on the to the the hand is 200 N/cm2 and 0.49 J of energy } \\ \hline
\multicolumn{1}{|l|}{References} & \multicolumn{4}{l|}{\ref{sup:DS/ISO/TS15066} \ref{sup:ISO10218-2}} \\ \hline
\rowcolor[HTML]{FFCC67}
\multicolumn{5}{|l|}{\cellcolor[HTML]{FFCC67}Risk estimation} \\ \hline
\multicolumn{1}{|l|}{Degree of Possible Harm:} & \multicolumn{2}{l|}{0.5} & \multicolumn{1}{p{4.5cm}|}{Probability of occurrence of Hazardous Event:} & 1.25\\ \hline
\multicolumn{1}{|l|}{Possibility of Avoidance:} & \multicolumn{2}{l|}{0.75} & \multicolumn{1}{l|}{Frequency of exposure:} & 4 \\ \hline
\rowcolor[HTML]{FFCC67}
\multicolumn{5}{|l|}{\cellcolor[HTML]{FFCC67}Risk Evaluation} \\ \hline
\multicolumn{1}{|l|}{Pliz Hazard Rating (PHR):} & \multicolumn{2}{l|}{1.875} & \multicolumn{1}{l|}{Summary level} & \cellcolor[HTML]{32CB00} Negligible Risk \\ \hline
\rowcolor[HTML]{FFCC67}
\multicolumn{5}{|l|}{\cellcolor[HTML]{FFCC67}Risk reduction} \\ \hline
\multicolumn{5}{|p{\linewidth}|}{Not needed, because of the low impact damage and the speed of the robot makes it possible for the operator to avoid the robot. Therefor it is not very likely that the hazard will happen but the operator will still be exposed to the hazard fairly frequent.} \\ \hline
\end{tabular}
\end{table}
Which gives the following output:
table

Minipage in Latex failing to compile

I want to put a table and figure above/below one another in my article tex file as they are related. Until now it has worked in this document but suddenly it isn't working and I can't compile in Overleaf. Please help.
\begin{document}
\begin{minipage}[b]{1\textwidth}
\centering
\captionof{table}{Best Case Scenario A IC values when synthesis, desiccation (and algae collection) have been excluded from the system.}
\label{tab:BestA_synthANDdesiccation_excluded}
\begin{tabular}{#{}llcc#{}}
\toprule
IC & Unit & Total (no collection) & Total (with collection) \\ \midrule
CC & kg CO2 eq & -1.1E+03 & -7.0E+02 \\
Ecotox & CTUe & 2.1E+02 & 1.4E+04 \\
HTnc & CTUh & 6.9E-08 & 1.4E-05 \\
PM & disease inc. & 3.7E-07 & 1.0E-05 \\
RUf & MJ & 9.3E+01 & 5.6E+03 \\
RUm & kg Sb eq & 8.0E-06 & 3.6E-02 \\ \bottomrule
\end{tabular}
\end{minipage}
\begin{minipage}
\includegraphics[width=1\textwidth]{Pictures/A_best_nosynANDnodesiccationANDnocollection.png}
\captionof{figure}{Characterisation of the sub-systems in best-case scenario A when synthesis, desiccation and algae collection have been excluded from the system boundaries. Method: EF 3.0 Method (adapted) V1.00}
\label{fig:Abest_nosyn_nodesiccation}
\end{minipage}
\end{document}
The main problem is that the minipage has an mandatory argument to specify the width, so you'll need
\begin{minipage}{\linewidth}
Some other comments:
best not specify a file type for your image \includegraphics[width=1\textwidth]{Pictures/A_best_nosynANDnodesiccationANDnocollection}. If you have the same image in different formats latex will then include the one best suited for the engine you use to compile your document
Unless your minipage is in a float environment like figure or table you want to add \noindent before the minipage. Without this there is not enough space in your line to fit a minipage with \textwidth
if you want to have the numbers in your table nicely aligned, have a look at the siunitx package
\documentclass{article}
\usepackage{caption}
\usepackage{booktabs}
\usepackage{graphicx}
\begin{document}
\noindent%
\begin{minipage}[b]{1\textwidth}
\centering
\captionof{table}{Best Case Scenario A IC values when synthesis, desiccation (and algae collection) have been excluded from the system.}
\label{tab:BestA_synthANDdesiccation_excluded}
\begin{tabular}{#{}llcc#{}}
\toprule
IC & Unit & Total (no collection) & Total (with collection) \\ \midrule
CC & kg CO2 eq & -1.1E+03 & -7.0E+02 \\
Ecotox & CTUe & 2.1E+02 & 1.4E+04 \\
HTnc & CTUh & 6.9E-08 & 1.4E-05 \\
PM & disease inc. & 3.7E-07 & 1.0E-05 \\
RUf & MJ & 9.3E+01 & 5.6E+03 \\
RUm & kg Sb eq & 8.0E-06 & 3.6E-02 \\ \bottomrule
\end{tabular}
\end{minipage}
\begin{minipage}{\linewidth}
\includegraphics[width=1\textwidth]{example-image-duck}
\captionof{figure}{Characterisation of the sub-systems in best-case scenario A when synthesis, desiccation and algae collection have been excluded from the system boundaries. Method: EF 3.0 Method (adapted) V1.00}
\label{fig:Abest_nosyn_nodesiccation}
\end{minipage}
\end{document}

How to fix an extra alignment and illegal character error when making a table in LaTex, Overleaf

I have created a table in Latex and it has stopped displaying it but I need it to work on the document I am currently working on. When I input into a new document, it works again. I am getting the following errors:
LaTex error: Illegal character in array arg. Overfull \Hbox (56.47151pt too wide) in paragraph at lines at lines 70--98
Error alignment tab has been changed to \cr.
It does not work either when I include the array package. I am using the following packages:
\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{url}
\usepackage[round]{natbib}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{float}
\usepackage{amsmath}
\usepackage[toc,page]{appendix}
\begin{table}[h!]
\begin{center}
\caption{A comparison between Rwanda and The Gambia}
\begin{tabular}{l|s|r|m}
\textbf{Variable} &
\textbf{Specific Variable} &
\textbf{Rwanda} &
\textbf{Gambia} &
\hline \hline
\textit{Size} & Surface area (sq. km) & 26,340 & 11,300 \\
& Population (total) & 12,208,407 & 2,100,568 \\
\hline
\textit{Economy} & GDP growth (annual \%) & 6.1 & 4.6 \\
& GDP per capita & 720 & 680 \\
\hline
\textit{Education} & Literacy rate (gender parity index) & 1.029 & 0.851 \\
& School enrolment (primary \% gross) & 133.425 & 97.115 \\
& School enrolment (secondary \% gross) & 32.988 & 57.096 \\
& School enrolment (tertiary \% gross) & 6.695 & 3.094 \\
\hline
\textit{Health and Survival} & Life expectancy at birth (total years) & 67.129 & 61.193 \\
\hline
\textit{Politics} & Political Elections & 4 & 8 \\
& Freedom Rights Score & Not Free & Not Free \\
\hline
\textit{Gender Equality} & Gender equality rating & 4.5 & 3.5 \\
& The Global Gender Gap Report& 121 & 6 \\
\hline
\textit{Aid Rates} & Net ODA received per capita & 100.373 & 128.356 \\
& Net official development assistance & 37.3 & 46.8 \\
\end{tabular}
\end{center}
\end{table}
Concerning the first problem, "Illegal character in array arg", it is indeed cause by by an unrecognised argument to tabular.
Legal arguments are supposed to describe column types and are c (centered), l (left aligned), r (right aligned), p{width} (top aligned paragraph) and | to describe an intercolumn rule for the most common ones. There are packages that add extra column types, but in your code \begin{tabular}{l|s|r|m} 's' is unknown and do not correspond to a valid column type. 'm' exists to specify a middle aligned paragraph in the 'array' package; it would require the insertion of the package and an extra argument with the desired width of the paragraph. Just change 's' and 'm' wih legal parameters and all is OK. There are many documentation available that describe valid column types.
The second message says that you specify an array with four columns but the fist line contains 5 entries:
\textbf{Variable} &
\textbf{Specific Variable} &
\textbf{Rwanda} &
\textbf{Gambia} &
the fifth one is an empty entry following the ampersand after 'Gambia'. Replace it with an end-of-line to suppress the problem.
Here is a corrected version.
\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{url}
\usepackage[round]{natbib}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{float}
\usepackage{amsmath}
\usepackage[toc,page]{appendix}
\begin{document}
\begin{table}[h!]
\begin{center}
\caption{A comparison between Rwanda and The Gambia}
\begin{tabular}{l|c|r|c}
\textbf{Variable} &
\textbf{Specific Variable} &
\textbf{Rwanda} &
\textbf{Gambia} \\
\hline \hline
\textit{Size} & Surface area (sq. km) & 26,340 & 11,300 \\
& Population (total) & 12,208,407 & 2,100,568 \\
\hline
\textit{Economy} & GDP growth (annual \%) & 6.1 & 4.6 \\
& GDP per capita & 720 & 680 \\
\hline
\textit{Education} & Literacy rate (gender parity index) & 1.029 & 0.851 \\
& School enrolment (primary \% gross) & 133.425 & 97.115 \\
& School enrolment (secondary \% gross) & 32.988 & 57.096 \\
& School enrolment (tertiary \% gross) & 6.695 & 3.094 \\
\hline
\textit{Health and Survival} & Life expectancy at birth (total years) & 67.129 & 61.193 \\
\hline
\textit{Politics} & Political Elections & 4 & 8 \\
& Freedom Rights Score & Not Free & Not Free \\
\hline
\textit{Gender Equality} & Gender equality rating & 4.5 & 3.5 \\
& The Global Gender Gap Report& 121 & 6 \\
\hline
\textit{Aid Rates} & Net ODA received per capita & 100.373 & 128.356 \\
& Net official development assistance & 37.3 & 46.8 \\
\end{tabular}
\end{center}
\end{table}
\end{document}

How can I align CENTER (Horizontal Top) the content in the highlighted columns?

I am new to latex and stuck in the formatting and alignment of the table. I have also attached a screenshot.
CODE:
\begin{landscape}
\begingroup
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
%\renewcommand{\arraystretch}{0.8}
\begin{table}
\footnotesize
\linespread{1.2} % this decrease the vertical spacing between lines
\rmfamily % without this, \linespread doesn't give expected effect
\caption{Datasets used in our study, (1 Gbyte = 10\textsuperscript{9} bytes)}
\begin{tabular}{ p{0.7em} p{7.5em} p{2.3em} p{2em} p{2em} p{18em} | p{2em} p{2em} p{2em} p{18em} } \hline
\multirow{2}{*}{SN} & \multirow{2}{*}{\begin{tabular}[c]{#{}l#{}}Tools (version; \\ compression type)\end{tabular}} & \multicolumn{4}{c}{\textit{k = 28}} & \multicolumn{4}{c}{\textit{k = 55}} \\ \cline{3-6} \cline{7-10}
& & \begin{tabular}[c]{#{}c#{}} Time\\ (s)\end{tabular} & \begin{tabular}[c]{#{}c#{}}RAM\\ (GB)\end{tabular} & \begin{tabular}[c]{#{}c#{}}Disk\\ (GB)\end{tabular} & \begin{tabular}[c]{#{}l#{}}CPU utilization (\%) \\ (comment)\end{tabular} & \begin{tabular}[c]{#{}c#{}} Time\\ (s)\end{tabular} & \begin{tabular}[c]{#{}c#{}}RAM\\ (GB)\end{tabular} & \begin{tabular}[c]{#{}c#{}}Disk\\ (GB)\end{tabular} & \begin{tabular}[c]{#{}l#{}}CPU utilization (\%) \\ (comment)\end{tabular}\\ \hline
1 & Jellyfish (2.2.6) & 138.33 & 7.9 & 0 & 1093.55 (consistent) & 226 & \textit{\textbf{36.19}} & 0 & \textbf{1050.93* (consistent)} \\
2 & DSK (2.2.0) & 56.33 & 6.35 & 6 & 866.50 (consistent) & 78.33 & 7.04 & 5 & 633.49 (declined from $\sim$1174 to $\sim$129.7) \\
3 & DSK (2.2.0; gzip) & 194 & 4 & 6 & 402.71(first 80\% of time consistent with $\sim$300; last 20\% inconsistent to $\sim$1200 with sudden increase) & 222 & 6 & 5 & 441.21 (first 75\% of time consistent with $\sim$390; last 25\% inconsistent to $\sim$1200 with sudden increase) \\
\end{tabular}
\end{table}
\endgroup
\end{landscape}
You can use the siunitx package. It defines a new column type S that aligns numbers on their decimal point.
The package was completely perturbed by your overly complex table, with many nested tables in it. In general, you should never need to do that. I have rewritten your table in a much simpler and more readable way.
Note that an S column needs to have a numeric entry. If you have some text (for instance in a header), you can
redefine the type of the cell to c (or l, p, etc) \multicolumn{1}{c}{text entry}
or simply enclose your entry in braces {text entry}
\documentclass{article}
\usepackage{lscape}
\usepackage{array}
\usepackage{multirow}
\usepackage{siunitx}
\begin{document}
\begin{landscape}
\begingroup
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
%\renewcommand{\arraystretch}{0.8}
\begin{table}
\footnotesize
\linespread{1.2} % this decrease the vertical spacing between lines
\rmfamily % without this, \linespread doesn't give expected effect
\caption{Datasets used in our study, (1 Gbyte = 10\textsuperscript{9} bytes)}
\begin{tabular}{ p{0.7em} p{7.5em} SSS p{18em} | SSS p{18em} }
\hline
\multirow{2}{*}{SN} &Tools (version; &\multicolumn{4}{c}{\textit{k = 28}} & \multicolumn{4}{c}{\textit{k = 55}} \\
\cline{3-6} \cline{7-10}
&compression&{Time}& {RAM}& {Disk}&{CPU utilization (\%)}&{Time}& {RAM}&{Disk}&{CPU utilization (\%)}\\
& type) &{(s)} &{(GB)}&{(GB)} &{(comment)} &{(s)} &{(GB)}&{(GB)}&{(comment)}\\
\hline
1 & Jellyfish (2.2.6) & 138.33 & 7.9 & 0 & 1093.55 (consistent) & 226 & \textit{\textbf{36.19}} & 0 & \textbf{1050.93* (consistent)} \\
2 & DSK (2.2.0) & 56.33 & 6.35 & 6 & 866.50 (consistent) & 78.33 & 7.04 & 5 & 633.49 (declined from $\sim$1174 to $\sim$129.7) \\
3 & DSK (2.2.0; gzip) & 194 & 4 & 6 & 402.71(first 80\% of time consistent with $\sim$300; last 20\% inconsistent to $\sim$1200 with sudden increase) & 222 & 6 & 5 & 441.21 (first 75\% of time consistent with $\sim$390; last 25\% inconsistent to $\sim$1200 with sudden increase) \\
\end{tabular}
\end{table}
\endgroup
\end{landscape}
\end{document}

Resources