Economics should be open

November 17, 2008

perl script for transposing Stata outreg2 output

Filed under: Data Insights, Stata, coding — Tags: , , — howardchong @ 10:38 pm

I’m using Stata’s outreg2 command and love it. But I run this look over 600 stocks. Excel doesn’t allow me to view 600 columns (Except in the newer version).  So, I need to transpose the outreg2 file. It’s too wide. Too many columns.

My former post on someone else’s perl script (http://opensourceeconomics.wordpress.com/2008/10/02/perl-script-for-transposing-csv/) actually doesn’t work correctly. I had to make two modifications, and the result is the perl script downloadable from here:

http://are.berkeley.edu/~chong/filesforblog/transpose_tsv_hc.pl

The two modifications are that 1) files are saved with tabs rather than commas. No big deal, I just changed the split operator and 2) the original script freaked out when there were blanks in the data. All blanks are ignored.

1 Comment »

  1. Here are step-by-step instructions

    1) Download and install some form of Perl.
    2) Download the .pl file
    3) You might have to make it executable (Linux).
    4) On windows, run “cmd” to get a command prompt
    5) type “perl transpose_tsv_hc.pl filename.txt”
    6) You will now have a “tr_filename.txt” where the columns and rows are transposed.

    Comment by howardchong — November 17, 2008 @ 10:44 pm


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.