Econometrics blog

Nov 4, 2014

leading zero in string variable

A typical example might be to convert the following numbers 

> to a standard five-digit number with leading zeros:
> 2 -->  00002
> 33 --> 00033
> 473 --> 00473
> 59724 --> 59724

Display with leading zeros is a matter of format:
di %05.0f 2 

A more fundamental change is: 
gen str5 newvar = string(oldvar,"%05.0f") 

Oct 26, 2014

create label value from variable in stata

buat label value dari country, dari kode negara

we can use command labmask
. labmask kdnn, value(country)

. tabdis kdn, cellvar(kdnn country)

--------------------------------------------------
      kdn |               kdnn             country
----------+---------------------------------------
      001 |        FRANCE                    FRANCE
      003 |        NETHERLANDS       NETHERLANDS
      004 |        GERMANY                GERMANY
      006 |        UTD. KINGDOM       UTD. KINGDOM
      007 |        IRELAND                  IRELAND
      008 |        DENMARK              DENMARK


Sep 29, 2014

LaTeX: Change subsection numbering

If you want to change the subsection numbering, you have to renew the command first as follows:

\renewcommand\thesection{\roman{section}}
\renewcommand\thesubsection{\thesection.\roman{subsection}}
 
with similar commands like \thesubsubsection and so on 
of course, there's also \thechapter (in the book and report class) and \thepart.
Commands to typeset numbers include:
  • \arabic (1, 2, 3, ...)
  • \alph (a, b, c, ...)
  • \Alph (A, B, C, ...)
  • \roman (i, ii, iii, ...)
  • \Roman (I, II, III, ...)
  • \fnsymbol (∗, †, ‡, §, ¶, ...)
  •  
If you want to change numbering in \enumerate, use this:

\usepackage{enumerate}
.
.
.
\begin{enumerate}[(a)] % (a), (b), (c), ...
\item
\end{enumerate}
.
.
.
\begin{enumerate}[a)] % a), b), c), ...
\item
\end{enumerate}


 

Sep 19, 2014

LaTeX: Alligning long equation and manually input equation number


If your equation is too long, you can insert the following comment in the equation environment, with the \\ to break line.

\begin{equation}
\begin{aligned}
 ..... \\
........
 \end{aligned}
\end{equation}

for example:

\begin{equation}\label{e10}
 \begin{aligned}
  \text{ln VA} = lnQ_3 + 1/ \sigma_y lnMP + lnA + \alpha lnK + (1-\alpha + \varepsilon)\\
   \times ln (N-a_0 N^{3/2}) + (1-\rho)/\rho((1+MS)^{-1} ln(N-a_0N^{3/2})).
 \end{aligned}  
\end{equation}


If you want to manually set equation number just put \tag{equation number} in the end of the equation:

\begin{equation}\label{e10a}
\begin{aligned}
 \text{ln VA} = lnQ_3 + 1/ \sigma_y lnMP + lnA + \alpha lnK + (1-\alpha + \varepsilon)\\
   \times ln (N-a_0 N^{3/2}) + (1-\rho)/\rho((1+MS)^{-1} ln(N-a_0N^{3/2})).
   \end{aligned}   \tag{10a}
\end{equation}

LaTeX: Reduce line spacing in enumerate environment


To change enumerate, you must install package enumitem
\usepackage{enumitem}

to change enumerate globally:
\setlist[enumerate]{itemsep=0mm}
 
 to change enumerate locally,
\begin{enumerate}[itemsep=3mm]


 for example:


\documentclass{article}
\usepackage{lipsum}

\usepackage{enumitem}
\setlist[enumerate]{itemsep=-5mm}

\begin{document}

\lipsum[1]
\begin{enumerate}
    \item one
    \item two
\end{enumerate}

\lipsum[2]
\begin{enumerate}[itemsep=5mm]
    \item one
    \item two
\end{enumerate}
\end{document}