Fair warning: this post is off the nerd deep end.I’m going to describe how to use the Notepad++ text editor and the Stata package texdoc to edit Stata and LaTex code from within the same document. So this post will assume a basic level of interest in and knowledge of Stata and LaTex. Here goes!

During my coursework at UIUC I got acquainted with R and was particularly taken with the Knitr package for writing reproducible reports.

Brief discursus on why this matters: reproducible research is a growing preoccupation in the social sciences, especially with recent high-profile spats about p-hacking and reproducibility in the psychology literature. Reproducibility actually encompasses a number of questions, the most obvious being, “if I did the same experiment over again, would I get the same result?” But even before you get to attempting to re-run an experiment (which in economics is tricky, since we don’t exactly work in labs…) there is a lower bar to pass: “if I ran the same code on the same data would I get the same result?” That might seem like an obvious and easy test, but there are a number of documented cases where papers submitted to peer-review journals have failed it. So there is a push within economics to publish the code used in the statistical analysis along with the data and the analysis itself.

Reproducible documents make that task a lot easier. Using a tool like Knitr, you can write a report or paper, including snippets of R so that the code can be edited along with the analysis rather than copying and pasting tables back and forth. This eliminates some possibilities for errors and keeps you from including old tables when the model or the data changes. It also simplifies and organizes the task of providing code and data, because everything is all in one place. Most importantly for the lazy grad student in all of us: it saves a lot of time. Moving to RStudio with Knitr saved me considerable time, because each table was automatically regenerated inside my document any time the code changed.

Which brings me to my major beef with Stata: where’s the equivalent of Knitr? Enter texdoc. This is a Stata package that allows you to write LaTex (the markdown language used to format papers for publication) and Stata code within the same document. This means you can write a report, format it, and run the Stata analysis all in one place, no copying and pasting needed. So…

What You Need:

  1. texdoc and sjlatex Stata packages
  2. Notepad++ text editor
  3. A distribution of LaTex (I used MikTex v. 2.9)

Step 1: Install texdoc and sjlatex

First, to get Stata to allow LaTex code inside your .do files, install texdoc by typing ssc install texdoc into the Stata command line. Then consult the texdoc help file and this paper by Ben Jann for how to include LaTex code inside your .do files.

Next, in order to get LaTex to properly read your Stata output, install sjlatex. Instructions are available here for installing sjlatex and getting your installation of MikTex to find it.

Note: the file “stata.sty” included in the sjlatex package is essential for telling MikTex how to format Stata output. I’m sure there is a more elegant way to do this, but I had to put that file into my LaTex project’s working directory, i.e. the folder where the LaTex pdf files are generated, in order to get MikTex to recognize it.

Now play around with writing LaTex and Stata code, placing LaTex code inside /*tex and tex*/ tags. This will allow you to write a document complete with a LaTex header, sections of text, and a bibliography, while spitting out your Stata output from within the same file.


As you can see above, my LaTex header is treated as a comment (shout-out to Mani at UIUC for his primer on LaTex). So Stata ignores the LaTex, then produces a separate .tex file which you can run MikTex on to produce the final formatted document.

End of story?

Unfortunately no. If you try this out for yourself, you’ll find a few flaws in the workflow, mainly stemming from the limitations of Stata’s native .do file editor. It is just not set up for writing an entire document. It doesn’t have spell-check, it doesn’t wrap text (so a paragraph is one long line), and it will definitely not help you with your LaTex syntax.

So it’s time to ante up and use a real text editor to work with the .texdoc files you’ll be writing with this package. There are two very good options for this task: SublimeText and Notepad++. You can check out how to use SublimeText with Stata here, but I’ll be focusing on Notepad++ because I have a bias for open-source tools, and I already had it installed when I was working this out.

Step 2: Configure Notepad++ to work with Stata

Install Notepad++, then follow the instructions here to install Freidrich Huebler’s extension rundolines. This will allow you to write Stata code in Notepad++ then execute it in Stata.

Note: This requires some fussing with the code in the programs Huebler provides. Make sure you get the file path to Stata entered correctly, and edit the code so it refers to your version of Stata. I futzed with this for a while before realizing the code pointed to Stata 14.0 and my version is 14.1.

Next, to get Notepad++ to recognize Stata commands and provide syntax highlighting, follow these instructions from Konstantin Golyaev to set Stata code as a user-defined language.


Now you can choose Stata as one of the languages. Note that Tex comes pre-installed under “T” in the menu pictured above, so you can toggle between the two languages as you write.

Step 3: Configure Notepad++ to work with LaTex

John Bruer has thorough instructions here for setting up Notepad++ so that you can run LaTex to generate documents and even search back and forth between the final document and the code that produced it.

Note on references: The code in Bruer’s instructions above uses Bibtex to generate references. If you prefer Biber (which is more recent and has more options) you’ll need to substitute biber.exe for bibtex.exe in the pdf_latex.bat file. And again, pay close attention to the paths to the various programs that are being called.

Step 4: Put it all together

Now that Notepad++, Stata and LaTex can all talk to each other, it’s just a matter of settling on a workflow that works for you. I tend to keep three files going in Notepad++ at a time: the .texdoc file, the .tex file, and a master .do file that gets everything started. The master do file just has a few lines of code like this:

cd “example working directory”
set more off
texdoc do example.texdoc
texdoc strip example.texdoc, replace

This sets the working directory, initiates the .texdoc file, and creates a separate .do file with just the Stata code, in case I want to look at or share the code without all the LaTex stuff.

So to run the whole thing, I execute the master .do file, which runs all the code in the .texdoc file, generating both my stripped .do file and a .tex file in the process.


Then I click over to the .tex file’s tab and run MikTex using the pdflatex_build command (which I’ve set as keyboard shortcut F8), and there it is: a nicely formatted pdf with paragraphs of text and Stata-generated tables all included.


So that’s that! Using texdoc with Notepad++ you can write reproducible papers and reports and look like a boss doing it. If anyone reading this has any additional improvements or modifications they’ve made, please share them.



  • In Thai, one word (tam), suffices for both “make” and “do.” The same is true for the Tajik kardan and the Spanish hacer. English is the only language I’ve yet learned that separates the idea of action from that of creation.
  • When Thais say they are eating, they say they are eating rice. When they say they are hungry, they say they are hungry for rice, whether they plan to eat rice or not. Rice is food. The real food. This linguistic association of the staple with the very concept of food is common. Congolese will often say they have not eaten today if they have not yet eaten manioc.

continue reading at Curator Magazine.

If there is an Oscar for the category, “best glorification of the life of the mind” then Hannah Arendt deserves it. Rarely have the classroom and the writing desk glowed with more fervor on-screen than in Margarethe Von Trotta’s biopic of the acclaimed Jewish political theorist.

It’s a winning presentation. Barbara Sukowa’s Arendt is a lantern-jawed hero of independent thought, steely-eyed in the face of criticism.

And that criticism is stiff, for Hannah Arendt chooses to center its drama around Arendt’s coverage of the Adolf Eichmann trial and the writing of the subsequent book, Eichmann in Jerusalema period in Arendt’s life when she was embroiled in controversy. The film makes much of this drama, reminding the viewers that what is now familiar in the history of ideas was once too hot to handle.

Click here to continue reading at Curator Magazine.

Sad as it is, the time has come for me to return to the United States. The folks at the seed bank and Chiang Mai treated me to farewell dinners, and I said my farewells. I will miss Thailand, and all the people I met there. I learned a lot about seeds, food, agriculture, development, and Southeast Asian culture while I was there. It was a remarkable, interesting place to live and work.

But there is an end to everything. Fortunately, I didn’t have to fly straight back. Instead, I took the train from Chiang Mai to Bangkok and had a whirlwind two-day tour of Thai art and culture. Here are some photos of the adventure:

Some wilted lotus buds at a shrine in the Temple of the Emerald Buddha.


A child looks at some lotus flowers in front of a lovely example of Ficus religiosa, the Bhodi tree, under which the Buddha is said to have received enlightenment.


Some students taking a tour of the Temple of the Emerald Buddha.


A lock in the Grand Palace, bedecked with a small garland of flowers, for reasons mysterious to me.


A crucifix in the Silpakorn University gallery of sculpture. Behind it, Buddha’s head.


A profile of Florentine sculptor Silpa Bhirisri (born Corrado Feroci), the namesake of Silpakorn university, and the man most responsible for introducing modern art to Thailand. He was made the King’s official sculptor in 1924, and went on to train most of the prominent artists of Thailand. His motto, “Vita brevis, ars longa” (“Life is short, art is long”–or perhaps, “life is brief, art endures”) adorns the entrance to the university.


Chinatown at dusk.


Looking over Salvador Dali’s shoulder at an installation at the Bangkok Museum of Contemporary Art.


The most striking piece I saw at the MOCA: like many examples of Buddhist art, it contemplates mortality in vivid, if not grotesque, detail. But something about the attention paid to the old man in this painting strikes me as loving. An example, perhaps, of the ethic of compassion in Buddhist thought which, to an outsider like me seems to run counter to the idea of detachment. The artist seems to say that detachment from the self allows compassion for the other–even if all things are as insubstantial as the old man’s grasp on life. But you’re free to draw your own conclusions.


A silk-weaving loom at the late Jim Thompson’s house. Thompson, like Corrado Feroci, entered Thailand at a pivotal point in its transition to cultural and economic openness. He visited during the Vietnam war (in which he may have participated as a CIA operative), and stayed when the war ended. Thompson played an important part in marketing Thai silk abroad, and assembled a remarkable collection of Thai art and architecture in his home. This brought him a peculiar mixture of respect, gratitude and resentment in Thai society, as described in this article in the Paris Review. He disappeared in 1967 under mysterious circumstances while hiking in Malaysia.


Artists preparing an installation outside the Bangkok Arts and Cultural Centre.


A closer look at an artist at work.


In addition to going to an Easter service, (where I arrived at the usual time only to find out the other folks had been there since 5:00 am!) I spent Easter weekend listening to a lot of music from around the world. Here’s a run-down of a few highlights.

We have a visitor from Myanmar this month named Leon, a very cool guy who works with an NGO in Yangon. He’s come to learn a bit about agriculture and nonprofit work in Thailand from UHDP. I’ve been trying to learn as much about Myanmar from him as I can. His favorite band is Iron Cross, a sort of musical collective made up of mostly ethnic Karen Christian musicians.

Iron Cross gets a lot of youtube love for their lead guitarist’s tap-soloing heroics, but I think they’re at their best when they go acoustic and give the mic to Lay Phyu, a singer known for love songs containing veiled criticisms of Myanmar’s military regime. According to Leon he was banned from the stage for 3 years because of his onstage political remarks.

The statement that got Lay in trouble bears description because it illustrates the contortions artists often go through to speak out in the context of repression. During a concert, as his brother–the group’s guitarist–joined him on stage, Lay reportedly told the audience, “only someone close to you can betray you.” The comment could be taken to refer to his brother stealing the spotlight from him, but the strength of the statement and its context indicated to the audience that he was really talking about the military’s betrayal of democracy. It’s amazing how little has to be said in order to communicate protest.

Another folk artist known for his political stance, Carabao is one of Thailand’s most enduring rock icons. You can see their trademark water buffalo logo on shirts, hats, truck tailgates and walls all across the country. They famously defied the leaders of the 1993 coup in Thailand, and got away with it thanks to their overwhelming popularity. Their most popular song is probably Made in Thailand, which celebrates Thai culture, but also slyly references “Made in Thailand” stickers on consumer products as a way to criticize consumerist culture and the global trade system.

Now to leave Southeast Asia. Maybe my favorite artist from anywhere in the world right now is Art Melody, an MC from Burkina Faso with a gritty voice and an exhilarating flow. I heard about him on the excellent music site His sound reminds me of a few other gravel-voiced West African rappers, like Batman Samini of Ghana and Messengers of Cote d’Ivoire (who were on a compilation by DJ /rupture a while ago), but I don’t know how much shared influence there really is there. I’m a newbie to West African music. But I love it.

You can stream his album Wogdog Blues below. Wogdog is a reference to Ouagadougou (pronounced wa-ga-doo-goo), the capital of Burkina Faso, where ECHO will soon have a regional impact center!

DSC07504Hot season is moving on and there are more and more mangoes in the market! Our mangoes here in the North are still little inch-long green babies, but I bought some today to get me primed for the season.

Mango, (mamuang in Thai, Mangifera indica to botanists) is native to Southeast Asia. In addition to the ripe fruit like the ones I brought home, there is a cultivar picked green and served with chili sauce. It’s a wonderfully intense mix of sour and spicy. A real treat.

Mango is botanically related to cashew, which, if you see it on the tree looks like a little mango with a cashew hanging on to the bottom. It’s also, strangely enough, related to poison ivy, and its sap contains the same toxin, so people who are highly allergic to poison ivy are generally also allergic to mango.

DSC07499Above is another mango relative: the gandaria, or plum mango. When I saw it in the market I mistook it for a tiny mango cultivar, but it is a different species in the same family (Bouea macrophylla). It does have the consistency of a plum, with a flavor that reminded me of nectarines and loquats.

Photo from wikipedia

Another new fruit I tried recently (but forgot to take a picture of myself) is the star apple (Chrysophyllum cainito). As fruit geeks can probably tell by looking at the seeds, it’s a member of the Sapotaceae family, relative to sapodilla and mamey sapote. Poetry geeks (yes I’m both of these) might recognize the name from Derek Walcott’s poem and collection, The Star-Apple Kingdom.

Star apple’s white flesh has a creamy texture, with more gelatinous flesh clinging around the seeds. It has a sweet, clear flavor like a pear.


So it’s time I talked a bit about what I actually do around here.

At the seed bank I’ve been given a research project examining the effects of different seed storage methods on long-term viability. The idea is to test different techniques, from the most resource intensive (sealed in vacuum packs with USAID-provided zeolite drying beads) to the most affordable (bamboo cylinders).

In the mix are a few intermediate technologies. One of my favorites is a vacuum-sealing method using mason jars and a bicycle pump. You turn the valves on the bicycle pump backwards and use it to draw a vacuum on the jar, as demonstrated by Lue, the seed bank production manager, below:


There are three main factors in determining seed viability in storage: oxygen, moisture and temperature.

Vacuum sealing is important because oxygen speeds up seeds’ deterioration. In a previous trial (written up in ECHO Asia Note 14), ECHO found that vacuum sealing was even more effective than cold storage in preserving seed viability. So given the choice between a refrigerator and a method of vacuum storage, go for the vacuum.

We’ll also be experimenting with different techniques for keeping moisture low. We’ll be testing four different desiccant to see what their long term effect is on seed storage: silica beads (like the ones you find in doritos bags), zeolite beads, zeolite powder and parched rice. Zeolite is a mineral substance filled with microscopic pores that allow it to absorb moisture.

For the final factor, temperature, we’ll be storing all the treatments in an earth-bag house, a well-insulated structure made of local materials that will keep the seeds at a fairly consistent temperature. The control will be the seed bank’s refrigerated cold room.

earth bag house

(photo by fellow intern Jen Smeage)

The idea with all these experiments is to assemble a range of tested technologies for seed savers and small-scale seed banks to choose from. No single package of techniques will be appropriate for ever farmer and institution: some will have electricity, some will not, some will have access to commercial desiccants, some will not. So we want to have data on a whole continuum of seed storage methods which we can recommend to our network of agriculturalists.

It’s exciting stuff I think. ECHO’s hope is that this information will empower people in Southeast Asia to improve their seed storage, which will in turn enable them to better steward the edible biodiversity of their farms, hedge against some of the risk involved in all kinds of agriculture, and take food security into their own hands.

That’s the grand vision. But really, I’m just playing around with seeds.