Rearranging Input Data
Posted: Mon Jun 21, 2010 2:46 pm
The following shows probably the simplest way to rearrange panel data that are in separate files for each variable in the "wrong" orientation. The data files are blocked as 40 rows (time dimension) by 19 columns (countries). If you read that by free-format using DATA, the data will be blocked the wrong way, with consecutive entries being different individuals for a single time period. While you can read that in the wrong orientation and use PFORM with the TRANPOSE option to rearrange it, it's probably simpler (and clearer) to read into a T x N array and copy information out of a "VEC'ed" version of that matrix.
Raw data files:
Raw data files:
Code: Select all
*
* Analysis of money demand function from Nelson C. Mark & Donggyu Sul,
* 2003, "Cointegration Vector Estimation by Panel DOLS and Long-run
* Money Demand," Oxford Bulletin of Economics and Statistics, vol. 65,
* no. 5, 655-680.
*
* Program to rearrange data from three separate data files
*
cal(panelobs=40)
all 19//40
*
* Rearrange the data, which are in a T x N block with a separate file
* for each.
*
dec rect ydata(40,19) xdata(40,19) zdata(40,19)
open data y.dat
read(unit=data) ydata
open data x.dat
read(unit=data) xdata
open data z.dat
read(unit=data) zdata
*
set realm = %vec(ydata)(t)
set realy = %vec(xdata)(t)
set rate = %vec(zdata)(t)
*
open copy panelmoneyx.xls
copy(format=xls,org=columns,nodates)