A good place to start reading on this topic is the SAS-SPSS-STATA FAQ on the UCLA STATA website. You'll see StatTransfer mentioned here, which is the most comprehensive package for switching between different types of data. However, this is a commercial package. There is a free version to download which converts 15 out of every 16 observations, but this is obviously undesirable for the perfectionist!
So I've been looking into data conversion possibilities besides StatTransfer, with an emphasis on the STATA user's point of view. The first thing I noted is that STATA reads in many types of data using infile, infile2, insheet, infix, odbc and fdause. Infile reads unformatted ASCII (text) data. Infile2 reads ASCII (text) data in fixed format with a dictionary. Insheet reads ASCII (text) data created by a spreadsheet. Infix reads ASCII (text) data in fixed format. Odbc reads Access, Excel and dBase files. Fdause reads datasets in FDA (SAS XPORT) format.
Besides all these possibilities, researchers can often find themselves with an SPSS file that they need to convert to STATA. It is possible to do this by opening the SPSS file (.sav) in SPSS and saving it in STATA .dta format (there are many formats to choose from). One thing I noted when saving to STATA format within SPSS is that SE should be selected when saving large (i.e. >250 obs.) data-sets. The highest STATA format available in SPSS 17 is STATA 8 SE, but this opens fine in STATA 9 and 10. It is also possible to get SPSS 17 on a free 30 day trial from the SPSS website.
As an alternative, there is a relatively new STATA plug-in called "usespss". It is available as a STATA ado-file here and here. It reads SPSS (.sav) files into STATA, but if one needs to convert portable SPSS (.por) files (as I did), then a version of SPSS will have to be used for conversion to .dta
Showing posts with label stata. Show all posts
Showing posts with label stata. Show all posts
Tuesday, December 16, 2008
Converting Between Different Types of Data
Some STATA Links
Masayuki Kudamatsu has put together the best page of STATA links that I have seen. Also found a neat introductory primer to STATA from the University of Minnnesota recently.
Monday, November 24, 2008
Thursday, November 20, 2008
A Stata Mind
For those interested STATA programming, the following blog will be of interest: A Stata Mind - Notes On Computing.
Wednesday, October 15, 2008
STATA Tutorials
Some good links for STATA tutorials:
1. Carolina Population Centre (my favourite)
2. Princeton
3. Northwestern
4. A South African Course
5. UCLA (alreday linked up on this blog)
Also useful is the STATA.com guide to STATA
Some STATA resources
A detailed introduction to STATA from Austin Nichols - probably best suited to those already familiar with regression and econometrics: http://pped.org/stata/IntroSt.pdf
A guide to interpretation of categorical dependent variable models using STATA:
http://ideas.repec.org/c/boc/bocode/s340701.html
The UCLA guide to doing regression and categorical coding with STATA:
http://www.ats.ucla.edu/stat/stata/webbooks/reg/default.htm
Thursday, October 2, 2008
Transitions across status in a categorical variable
In my firm-level dataset I have created a variable for the trading status of a firm in a given year, "tradestat", which looks as follows:
0: non-trading firms
1: exporter only
2: importer only
3: both imports and exports
The majority of firms keep the same trading status across their whole existence. There are, however, an interesting number of firms that switch trading status. My aim was to look at the ex-ante and ex-post productivities of the firms around their switching decision. It turned out to be pretty simple in the end.
Firstly, to get a transition matrix of the switchers and non-switchers, either of the following methods worked fine:
(1) xttrans tradestat, freq
(2) tab tradestat l.tradestat
To look at the ex-ante and ex-post (2 periods before and after) productivities around each switch, I first created a series of dummies:
gen switch01 = 1 if tradestat==1 & l.tradestat==0
This gives a 1 to every firm that was a non-trader in a given period and an exporter in the next.
gen switch02 = 1 if tradestat==2 & l.tradestat==0
This gives a 1 to every firm that was a non-trader in a given period and an importer in the next.
I did this for every potential switch (there are 12 as each of the 4 tradestat could move any of the other 3).
To look at ex-ante and ex-post productivities, I did the following:
su l2.productivity if switch01==1
su l2.productivity if switch02==1
and so on up to
su l2.productivity if switch32==1
for the ex-ante productivities
and
su f2.productivity if switch01==1
for the ex-post productivities
This enabled me to look at what it was I wanted in the beginning. Thanks to Christian, Liam and Fearghal for suggestions
0: non-trading firms
1: exporter only
2: importer only
3: both imports and exports
The majority of firms keep the same trading status across their whole existence. There are, however, an interesting number of firms that switch trading status. My aim was to look at the ex-ante and ex-post productivities of the firms around their switching decision. It turned out to be pretty simple in the end.
Firstly, to get a transition matrix of the switchers and non-switchers, either of the following methods worked fine:
(1) xttrans tradestat, freq
(2) tab tradestat l.tradestat
To look at the ex-ante and ex-post (2 periods before and after) productivities around each switch, I first created a series of dummies:
gen switch01 = 1 if tradestat==1 & l.tradestat==0
This gives a 1 to every firm that was a non-trader in a given period and an exporter in the next.
gen switch02 = 1 if tradestat==2 & l.tradestat==0
This gives a 1 to every firm that was a non-trader in a given period and an importer in the next.
I did this for every potential switch (there are 12 as each of the 4 tradestat could move any of the other 3).
To look at ex-ante and ex-post productivities, I did the following:
su l2.productivity if switch01==1
su l2.productivity if switch02==1
and so on up to
su l2.productivity if switch32==1
for the ex-ante productivities
and
su f2.productivity if switch01==1
for the ex-post productivities
This enabled me to look at what it was I wanted in the beginning. Thanks to Christian, Liam and Fearghal for suggestions
Friday, September 19, 2008
For the STATA user...
The Bank of England Introduction to STATA
Roy Wada's (RAND) Rapid Formation of Regression Tables for Research Purposes
Subscribe to:
Posts (Atom)