With one variable, that's easy enough: count if missing(variable-name). If you have several variables, you can put them in a foreach loop. But if you have to do this for arbitrary lists of variables in several files, it may be interesting to package that foreach loop inside a quick command that might handle special display [...]
Archives for the ‘Stata’ Category
Making Vim run Stata and clean up after itself
Tuesday, 2 March 2010
Last week I mentioned that in the course of switching from Notepad++ to Vim I lost the ability to run Stata do-files or selected lines from within the text editor, and I asked my readers for help if they had a solution. What do you know, one of them did, and wrote to me all [...]
Program vs. include smackdown
Sunday, 28 February 2010
When it comes to defining local macros in a different place from where you use them, you have two options: a do-file you include as needed or an r-class program that you call as needed. I talked about it here and said that a program is a better choice, without any evidence to back up [...]
I switched to Vim
Friday, 26 February 2010
I was looking for an excuse to try something new and I decided to pick on one Notepad++ shortcoming that was handy: the Stata syntax highlighting gets utterly mangled after compound quotes -- `"`like so'"' -- which do sometimes arise, usually in the process of file open/file write.
Vim does not get confused by compound quotes and [...]
Calling irregular arguments with syntax anything
Tuesday, 23 February 2010
The other day I wrote a program that needed to call a file as an argument -- with the full file path. My first pass at it was to capture the argument as usual, with say args input_file. But that would not have worked with file paths that have spaces in them. What might have [...]
Define local macros in one place, use them everywhere
Thursday, 18 February 2010
In The Stata Journal Vol. 9, No. 3, 2009 there's a Stata tip (# 77) on re-using macros in multiple do-files, by Jeph Herrin. His solution is to define any local macros in a separate do-file, say locals.do. You can call that do-file with the include command at the top of any do-file that might [...]
Back issues of the Stata Journal
Friday, 25 September 2009
I have this Twitter search saved in my Google Reader. It works OK. One recent tweet by DismalTrader linked to an old Stata Journal article about demand estimation, saved on Scribd. This reminded me that The Stata Journal has a three-year moving wall: anything older than three years prior to the latest issue is available free, [...]
Parenting with Stata
Sunday, 30 August 2009
My daughter will be eight days old by the time I'm done writing this. She's on food intake and diaper watch, so among the things we brought home from the hospital was this pink sheet where we were supposed to record full diapers and feeding patterns. Of course we then filled it out, and when [...]
Real FAQ’s
Tuesday, 11 August 2009
This list at the UNC help desk looks like it really was compiled from questions actually asked. That's always a good thing, so here goes. I hope you find it useful.
Regex tricks with Notepad++ and Statalist
Sunday, 2 August 2009
If you haven't heard, the do-file editor in Stata 11 comes with proper syntax highlighting, folding, etc. That means that this post will be obsolete as soon as I upgrade, unless the new do-file editor doesn't do regular expression-based find and replace. No matter. In the meantime, here goes:
People often post code on Statalist and [...]