\documentclass{article} \usepackage[margin=1in]{geometry} \usepackage{mathpazo,color} % Special formatting for chunks and output \StataweaveOpts{codefmt="formatcom=\color{blue}", outfmt="frame=single"} \begin{document} \section*{Stata Test} We'll look at the dataset they seem to use for all examples in the Stata manual: \begin{Statacode} sysuse auto summ mpg disp \end{Statacode} The maximum price is \Stataexpr{max(price)}. Let's generate new variables and fit a regression model \begin{Statacode} gen gp100m = 100/mpg gen for_disp = foreign*displacement label var gp100m "Gallons per 100 miles" regr gp100m foreign disp for_disp \end{Statacode} And here is a nice plot of the results \begin{Statacode}{fig, hide, height=4.5in, width=9in, dispw=4in} predict g_hat twoway (scatter gp100m disp) (line g_hat disp, sort), by(foreign) \end{Statacode} \subsection*{Using Mata} Let's try some matrix stuff, in case it Matas to you. \begin{Statacode} mata pr = st_data(.,("price")) printf("Price in thousands") pr' / 1000 \end{Statacode} The variable \texttt{pr} has \Stataexpr{rows(pr)} elements and its maximum value is \Stataexpr{max(pr)}, just as we computed before. \begin{Statacode} end /* Now we're back in interactive mode */ disp price/1000 \end{Statacode} \end{document}