It is possible to include a scalar value from stata into a latex document?
-
Login or Register
- Log in with
sysuse auto, clear scalar x = 99 forval n = 1/10 { scalar n`n' = `"`=make[`n']'"' } scalar li *could use file open/write commands but I prefer: texdoc init ex.tex, replace tex \documentclass{article} tex \begin{document} tex \begin{table}[ht] tex \caption{something here} tex \begin{center} tex \begin{tabular}{|c|c|} tex \hline Car make & Value \\ \hline \hline forval n = 1/10 { tex `=n`n'' & `=x' \\ } tex \hline \hline tex \end{tabular} tex \end{center} tex \end{table}% tex Here is some text referring to `=x' value and `=n2' tex \end{document} texdoc close
clear set obs 3 scalar x = "scalar" di `"`=x'"' di x //now gen vars using scalar 'x' g a1 = x //from scalar g a2 = `"`x'"' //this wont work yet g a3 = `"`=x'"' //from scalar l a* , div //now gen vars and a local 'x' local x "local" g x = "var" replace x = "var1st" in 1 //to see the difference scalar li di `"`x'"' di `"`=x'"' di `"`=x[1]'"' di `"`=x[2]'"' di x g b1 = x //now from variable g b2 = `"`x'"' //now from local g b3 = `"`=x'"' //now from only the first obs of variable x l x a* b* , div //examine the diff between a* and b*
Comment