stata are you there? it’s me, drek.

Like many relatively young sociologists I am an occasional, even frequent, user of Stata. While I have been assured- over and over again- by older and wiser heads that SAS is the way to go, I have generally found that Stata serves my needs rather well. It has been, as I have remarked before, quite free of the sort of insanity that often characterizes statistical software.

That is, until today. Today I was betrayed by my best statistical friend.

Today I had the experience of attempting to debug a do-file.* This, in and of itself, is not unusual- I often have to debug do-files as I am not perfect at writing code and do include the occasional typo. Alas, this particular error was quite intractable. I checked my spelling- all correct. I checked my syntax- just fine. I checked my placement of the command- no problem. So far as I could tell, the relevant line of code was perfectly, completely correct. I even tried adding a couple of hard returns before and after the command since, without those, Stata’s interpreter sometimes misses a line. No dice. Somehow, the command seemed entirely beyond my ken.

And then I tried something else: I typed the exact same command in manually through the command line interface, rather than via the do-file. And that, ladies and gentlemen, worked just fine. And in case you don’t believe me, I even took a screenshot:

This is the sort of behavior that I had come to expect from SAS but never, ever, from Stata. My world has been shattered, my faith in life permanently wounded! How shall I recover?

Eh. Whatever. As it turns out, it isn’t that big a deal. I had been running an older program in compatability mode with Stata 8.0, but once I upgraded the commands for Stata 9.2 the problem disappeared. Nevertheless, the damage has been done. I can no longer claim that Stata has been entirely trouble-free.

Et tu, Stata? Et tu?

* For the uninitiated, a do-file is often also referred to as a program, although it has more in common with a batch file. In any case, it's a whole series of commands that the stats package executes quickly rather than doing your stats line-by-line.

24 thoughts on “stata are you there? it’s me, drek.”

  1. It’s hard to tell from the screenshot but it looks like you have

    pweight-WTSS

    in the do file and

    pweight=WTSS

    in the line you entered manually. Did you copy and paste from your do file?

    Like

  2. Drek – if you’re using version control, this explains why the commands won’t work. I believe that Stata’s version control only works inside of the .do file. Once you exit the .do file, version returns control to v. 9.2. This matters because the syntax of the svyset command changed between version 8 and version 9.

    From the UCLA ATS website:

    Version 9 command:
    svyset house [pweight = wt], strata(eth)

    Version 8 command:
    svyset [pweigh=wt], psu(house) strata(eth)

    The PSU is defined as an option in Version 8 and in a varlist in Version 9. This would explain why Stata complains that “varlist not allowed” when in version control mode.

    And, FWIW, having used both SAS and Stata, I think Stata is a much better program than SAS. There are a few minor things that make Stata more cumbersome (being able to have multiple datasets loaded to memory is really nice in SAS, particularly working with multilevel data), but those are far outweighed by the number of things Stata makes easier.

    Like

  3. Mike3550 is correct. HighRes monitors not withstanding, I copied and pasted the commands in question. They are- most definitely- the same.

    Yeah, Jeremy, I’m not surprised I got the reference wrong. At least I’m better than my former boss who used to love to remark, “We need to follow K.I.S.S.: Keep It Stupidly Simple.”

    “Um, sir, that doesn’t mean what you think it does.”

    Like

  4. R is definitely the best, particularly if you like obscure syntax combined with enormous raw power.

    R’s syntax is a model of perfect clarity. It’s the help files that are obscure.

    Like

  5. I only ever learned R (thanks Bruce!) so I am like Moliere’s gentleman, discovering that I have been speaking functional programming all my life without knowing it.

    Like

  6. R. I mean, come on. This is the stats equivalent of those people who are discussing a problem they’re having with MS Word and having that inevitable person pop in to give a shout out to emacs. Really, you should be running R, with emacs, on your hand-coded debian machine, steampunked to look like a real computer.

    Kieran and Andrew, are you that inevitable person?

    Like

  7. Funny story, a professor of mine (Jon Miller, from USC) told me that as a graduate student they used to do computations on punch cards, and the competition was to find the repeating computation that would make the danciest, syncopated ka-chunk ka-chunk of the machine as it ran through the computation.

    Myself, I like to program directly in assembly language, and I use an abacus for calculations. Oh, and
    01001001001000000110110001101111011101100110010100100000011100110110111101100011011010010110111101101100011011110110011101111001

    Like

  8. Really, you should be running R, with emacs, on your hand-coded debian machine … Kieran and Andrew, are you that inevitable person?

    That’s the last time I save your ass when your Keynote presentation spontaneously borks itself in front of a large audience.

    Like

  9. @22: I’d like to say that Apple doesn’t bork, it’s only Microsoft that does; but what I really, truly want to say is, I take back everything I said about R users and their glorious contributions.

    BTW, I’m upgrading to osx 10.5. I’ll be asking for help on how to fix my machine/reboot from backup/re-making Unison in just a short while…

    Like

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s