Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: help with insheeting data

From   Ian Watson <>
Subject   Re: st: help with insheeting data
Date   Mon, 28 Nov 2005 16:24:06 +1100

Alexander Nerved asked about ways of outsheeting data from Stata, something which he does currently in Stat Transfer manually.

There are no doubt numerous ways to do this in Stata, but it's also possible to automate Stat Transfer to do various operations which you might be doing manually.

For example, here is some code to convert some SPSS data to Stata data.

winexec "c:\program files\stattransfer5\st" d:\data\

The file is a text file which lists the variables to bring in. A snippet of it follows:

vars "d:\data\source\Portable Rperson a30c.por"
XWAVEID // XW Cross wave ID
AHHRHID // DV: randomised household id
AHHRAID // DV: randomised area id
AHHRPID // DV: Randomised person ID
AHHPNO // HF Person Number
AHHIDATE // PQ Date of PQ interview

This can be easily modified to export from Stata data to ASCII fixed width. All the steps needed are documented in the Stat Transfer Command Processor help file.

Alexander Nervedi wrote:

Hi Statalist!

I am having issues with loading in data. I have a somewhat cumbersome
datatset - the data is first split into 10 domains, and within each domain,
I have data on a bunch of states in dbf format. Each state's file has two
state-cum-msa  identifiers and one 80 charecter long variable that needs to
be further split furhter according to a dictionary to get to the variables
for that state.

I can get to each of the files using

odbc load, table("statename") dns("data")

and then append them all to get one file that I can either output as a stata
file, or outsheet it.

So far so good.

The problem is that outsheeting it or even outfiling it introduces spaces in
the final file that mess up my dictionary file so that I can't read the 80
character long variable. The only way I can get it to work is by
Stat-transfering the file into *.dat format (ASCII Fixed Width + All program

Is there anyway I can export from within Stata to ASCII Fixed Width format?
This will automate the process of extracting my variables, instead of having
to manually run Stat Transfer on each time.

thank you,


Express yourself instantly with MSN Messenger! Download today - it's FREE!

*   For searches and help try:

Kind regards,

Ian Watson
Senior Researcher
acirrt, University of Sydney
NSW, 2006, Australia

phone: 02 9351 5622

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index