Photo credit: Stephen M. Scott
 +   -  text size:


All entries categorized “tips-n-tricks”

Making the Amazing Apportionment Machine

Wednesday, Aug. 21st, 2013 2:05p.m.

I was born in Northern Colorado and now live just outside the District of Columbia. I can attest from personal experience that these two places do not share much. Except, that is, for their desire to become states.

I was curious what would happen if both became states as a modern-day [Missouri Compromise]. I wrote the following script to make the Amazing Apportionment Machine to reapportion seats and looked at two scenarios: the current distribution of congressional districts and the distribution if "Northern Colorado" and the "State of Columbia" were added as states.

  tags: congress, tips-n-tricks

Basic Tips for Writing Statistical Scripts

Sunday, July 17th, 2011 6:14p.m.

While writing scripts is one of the most important skills for reproducible quantitative sociology, the typical convention is to pick up the skills through more experienced colleagues in graduate school or at the workplace. Below are a few tips that I have learned from others, picked up on my own, or otherwise accumulated in my arsenal of tricks that I thought that I would pass along. There are great resources out there, but I thought it would be helpful to pass along what I think are the most important and helpful tips.

  tags: Stata, tips-n-tricks, workflow category: Programming

Nesting Stata Macros, or Hacking a Hash Map

Monday, June 6th, 2011 6:37p.m.

Programming in Stata is relatively straightforward and this is partly because the programming syntax is both powerful and relatively straightforward. There are, however, a few minor annoyances in Stata's language including using the backtick and apostrophe to indicate local macros (i.e.,`localname'). Among these shortcomings, I would argue that the lack of anything like a list in Stata's language is one of the largest.

In most langauges, you can store a list of items and refer to the item in the list by some sort of index. This is particularly helpful for iterating over the same step multiple times. Lists generally come in two flavors: lists to which you can refer to an item by its position in the list or lists which you can refer to by a keyword (called hash maps in computer science lingo). Stata's matrices can be used for the first, though doing so might become complicated if you want to do something besides storing basic numbers or strings.

  tags: data-management, macros, Stata, tips-n-tricks category: Programming

Front Page


  • Information about the purpose and topics of this blog can be found here.






  • The views presented here are solely and entirely my own, they do not represent those of my colleagues, employer, or any funding agencies which may support me.
  • The writing on this blog is covered by a Creative Commons License (described here). Feel free to distribute or re-post with a link to the original content provided that it is freely available to others.
  • Creative Commons License