Economics should be open

March 27, 2009

Conditional Formatting Excel

Filed under: Excel — howardchong @ 12:01 am

I use conditional formatting a limited amount in Excel. It is great to visually highlight certain data. But It is not quite as useful as autofilter, which it seems like I use daily.

In any case, here are some good links for conditional formatting in the order of their usefulness to me:


March 26, 2009

Sample regular expressions for stata

Filed under: coding, Stata — howardchong @ 10:22 pm

Just a note to show how to use regular expressions in stata for text processing.

PROBLEM: I had a lot of codes in variable dsmnem the had “:” and “.” characters. I wanted to do a reshape my data and use these strings as the j variable, i.e. “reshape … j( dsmnem) string”
SOLUTION: regular expressions

replace dsmnem=lower(regexr(dsmnem,”:”,”_”))
replace dsmnem=regexr(dsmnem,”\.”,””)

These two lines replace periods and colons with emptytext and underscore respectively. Note that I have to use the escape character to specify the period character; otherwise the period has a special meaning in the regular expression.

Weird how they call it “regexr” and not “regexp” or “regexpr”, but whatever.

By the way, dsmnem is datastream mnemomic

Stata “unique” command helpful

Filed under: Stata — howardchong @ 9:58 pm

I just found the unique stata command.

PROBLEM: I have a correspondence table of companies to domains. One company can have multiple domains. I wanted a count of the number of unique companies.
SOLUTION: download the “unique” stata command. Install by running “ssc install unique”. You can also read more about it from the site:

ALTERNATIVE: I used to just do “keep company” and then “duplicates drop”. It was a hack, but it worked. If you have a small number, a easy way to do it is “tab company” and just count the lines.

March 25, 2009

How to scam the Geithner Plan

Filed under: bank bailout, Uncategorized — howardchong @ 9:50 pm

Marginal revolution posts a good description of the weakness of the Geithner Plan, i.e. how to game it:
Which refers to the Public-Private Investment Program.

Here I’m just trying to make it REALLY clear how the scam works and that the beneficiary of the scam is the banks. I initially looked into this trying to figure out if I could game the system and get rich. The answer to that is no. The only ones who can win big, is the banks.

I tend to bury the lede, so up front: the message is: The banks will book at most a $7 cost for every $100 to sell the asset at the AAA-rated price. Some estimates of the “market value” are $60. So instead of getting a $40 loss, they just pay $7 to get this junk off their books.

The assets will be sold at pretty-close to whatever the bank values them, which I’d guess is about 80cents per dollar. They could get 100 cents per dollar, but I would bet that’s too fishy.

Details below.

March 11, 2009

Data sources for Residential Energy/Electricity Data in California

Filed under: California, Energy, Residential — howardchong @ 10:32 pm

Perhaps no task is more vexing than doing a data search.

I’ve done a pretty thorough data search, over a several year period, with probably about 80 hours of work in here. The topic is residential energy/electricity data.

I’ve published this as a Google Document. You can access this document here:

Create a free website or blog at