Economics should be open

April 22, 2014

Sublime Text 2, adding stata syntax highlighting

Filed under: Uncategorized — howardchong @ 7:00 pm

I use non-Stata editors for do files because they look better an integrate better into my workflow. One editor I use is Sublime Text 2.

I use this because other programmers told me to use it. It’s great for HTML, Ruby, Python, etc. It’s not free, but there is a free evaluation version. It just bugs you in increasing frequency if you don’t register.

The killer feature for me is “Find in Files” CTRL+SHIFT+F. It lets me search all my do files for a command, gives me the results in a color coded file, and then I can double click to go to that file.

I also like that it is white text on black background. My eyes don’t like black text on white background. In fact, I think my preference is for yellow on black (old IBM) or cyan on black (old DOS days.)

Out of the box, Sublime Text 2 does not do syntax highlighting. So, you have to add it yourself.

The guide to do it is sorta here:

Except, that’s for textmate. Luckily, textmate uses the same syntax definitions. (I love programmers and reuse of code).
So here are the steps:

  1. download the file for textmate from and unzip
  2. navigate to Syntaxes\stata.tmLanguage
  3. Save this file in your user directory. For example, on Windows, my user directory is here: “C:\Users\howardchong\AppData\Roaming\Sublime Text 2\Packages\User”
  4. NOTE: If you can’t find your user directory, got to Sublime Text and do CTRL+` and then type: “sublime.packages_path()”. This will give you almost to the right path. Go to the “User” subdirectory and that’s the right path.

Text highlighting should now be enabled.

(NOTE: If this doesn’t work, you may also have to add package development. Follow the instructions here:


June 3, 2010

Tips for running long stata jobs, UNIX

Filed under: Uncategorized — howardchong @ 12:51 am

Here are some tips for running large stata jobs in linux/Unix


June 2, 2010

CEC climate zones, zip5, and California counties

Filed under: Uncategorized — howardchong @ 7:45 pm

I gathered shape files for california and produced the following spatial correspondence table:

CEC (California Energy Commission) Climate Zones (numbering 16).

zip5 (polygons)

CA counties (polygons)

I used this by using the ArcTool called INTERSECT.

I don’t have a great way of uploading the data, so if you want this data, help me upload it and it will be available to you (and everyone) for free.

March 1, 2010

Stata: how to make sure your file exists

Filed under: Uncategorized — howardchong @ 11:29 pm

Use this info here to check if a file exists in your stata code. Uses CAPTURE and return codes (_rc)

February 8, 2010

Fun with GIS, California zip9, cbg, latlon

Filed under: Uncategorized — howardchong @ 5:14 am

So, I’m having lots of “fun” with GIS right now.

I’m having to map zip9 (AKA zip+4, zip 9, zip5+4) in California to census block groups (and census tracts) (CBG / CT) and then to latitude and longitude.


November 2, 2009

Pitfalls of STATA robust estimation, a quick simulation study.

Filed under: Uncategorized — howardchong @ 11:50 pm

Use of “robust” after regress in Stata seems to be automatic. From the textbooks,  robust is more asymptotically efficient, and there is only a small hit for not assuming homoskedasticity.

There is one problem I am encountering, and that is in small samples. If your coefficient of interest has very little variation, be careful. Especially when measuring treatment effects where you have very few or very many treated observations.


July 29, 2009

Stata, control flow based on variable type

Filed under: Uncategorized — howardchong @ 12:45 am

Suppose you want to write a function (or a loop), where you do something to every variable that depends on its type. In matlab, I would use “isnumber”, etc, or just use the function that returns the type of the variable.

I couldn’t find such a function in stata. There is no “isnumeric” or “isfloat” function.

There is an extended function called “type”. This is my prefered way to do it:

local mytype : type myvarname
disp "`mytype'"

They also have “confirm”, which works:


July 28, 2009

octave error “error: invalid call to script”

Filed under: Uncategorized — howardchong @ 11:18 pm

I am new to Octave. I am using Octave 3.0 on windows (with octave-forge) and trying to call a script and get the following error:

“error: invalid call to script”

The fix?

I was trying to run hello1.m by typing


but I need to take the .m off and type


This error may also come up for different reasons, but this was my reason.

July 27, 2009

Input Output Table, generating from BEA data

Filed under: Uncategorized — howardchong @ 6:52 pm

I struggled a bit in putting together an input output  table (IO table) for the US economy in doing my research on the impact of carbon prices on industrial activity.

Here I include Octave (compatible with MATLAB) code to generate an input output table given 3 inputs from the Bureau of Economic Analysis:

  1. Total consumption
  2. Industrial activity linked to commodity (USE)
  3. Industries and how much of each commodity they produce (MAKE)



July 20, 2009

identity matrix in excel

Filed under: Uncategorized — howardchong @ 10:13 pm

So, excel can do matrix calculations. That’s useful. But why the hell didn’t it give us a function to create an identity matrix.

Here’s a quick hack (no programming) to generate an identity matrix.


Older Posts »

Blog at