Batch File Format Converter
Description
ftrans provides a batch process to exchange data of current directory between different spreadsheet and statistics programs.
Syntax
ftrans old_file_extension new_file_extension [options]
options Description ------------------------------------------------------------------------- /o- specifies that Stat/Transfer will not optimize the output data set to be as small as possible (as Stat/Transfer does by default). /oc specifies that Stat/Transfer will optimize the output data set to be as small as possible, and automatically drop constant or missing variables. /od specifies that Stat/Transfer will optimize the output data set to be as small as possible, but produce double precision variables where appropriate. /ocd specifies that Stat/Transfer will optimize the output data set to be as small as possible, and automatically drop constant or missing variables, but produce double precision variables where appropriate. /q specifies that Stat/Transfer will execute quietly, producing no messages, with the exception of error messages and warnings that a file is about to be overwritten. /r[page!]coor specifies a worksheet range, limited to page page and coordinates specified by coor, in an input worksheet file. The coordinates specify a top left and bottom right cell in the worksheet. For instance, /r2!b5:e75 specifies that the data are on page 2 of the input file, between the top left cell b5 and the bottom right cell e75. /s will turn on messages and leave the Stat/Transfer window open until the return key is pressed. This may be useful if Stat/Transfer appears not to be working. /ttablename is used in order to specify a table (or worksheet) within a data source containing multiple tables (or worksheets). /vversion_number specifies that Stat/Transfer will write the output dataset in the version of the appropriate format specified by the version_number, which should be a positive integer. If this switch is not specified, then Stat/Transfer writes the output dataset in the latest version of the appropriate format. /y specifies that files with the old_file_extension.ext will be overwritten, if it already exists. (If /y is not specified, then Stat/Transfer consults the user before overwriting files.) -------------------------------------------------------------------------
Examples
Convert all files in current directory (d:\temp) with old_file_extension .dta to new_file_extension .sav, or .sav to .sas7bdat:
. cd d:\temp
. ftrans dta sav
. ftrans sav sas7bdat
Convert all files with the file extension .sas7bdat to .dta, old .dta files will be overwritten with version 7.0 stata files:
. ftrans sas7bdat dta /y /v7
Technical note
Before using ftrans, you have to (1) install Stat/Transfer in your computer, and (2) set the global macro StatTransfer_path for the path of the Stat/Transfer st command, which is done easily by inserting a line into the user's profile do-file to initialize this path every time you starts Stata (if your Stat/Transfer has been installed in the directory of "c:\Program Files\StatTransfer10\" ):
global StatTransfer_path `"c:\Program Files\StatTransfer10\st.exe"'
Note that, when the user upgrades to a new version of Stat/Transfer, the upgrade creates a new directory, containing the new version of st.exe. Therefore, when Stat/Transfer is upgraded, either the user's default directory search path should be altered, or the line of code in the user's profile do-file setting the global macro StatTransfer_path should be altered.
Remarks
Stat/Transfer can be installed on Microsoft Windows, MacOS, and some Unix platforms. It is available from Stata Corporation and developed by Circle Systems.
References
ftrans supports the following file formats:
(If you have installed Stat/Transfer 10 in your computer)
1-2-3 (*.wk?) Microsoft Access (Versions 2.0 through Office XP version) (*.MDB; ACCDB) dBASE (all versions) (*.DBF) Delimited ASCII (*.CSV; *.TXT) Delimited ASCII with a Stat/Transfer SCHEMA file (*.STS*) Epi Info (*.REC) Excel worksheets (all versions, including Excel 2007) (*.XLS) Fixed format ASCII (*.dat) FoxPro (*.DBF) GAUSS (Windows and Unix) (*.DAT) JMP (*.JMP) LIMDEP (*.LPJ) MATLAB (*.MAT) MATLAB Seven Datasets Mineset (*.sch*) Minitab (*.mtw) NLOGIT (*.LPJ) ODBC data sources (Oracle, Sybase, Informix, etc.) (*.DBF; *.XLS; *.MDB) OSIRIS (read-only) (*.dic*; dct) Paradox (*.DB) Quattro Pro for DOS and Windows (*.WQ?; *.WB?) R (*.RData) S-PLUS (now supported through version 7) (*. ) SAS CPORT datasets and catalogs (read only) (*.stc) SAS for Unix¡ªHP, IBM, Sun (*.SSD*; *.sas7bdat) SAS for Unix¡ªDEC Alpha SAS for Windows and OS/2 (*.sd*; *.sas7bdat; *.ssd) SAS PC/DOS 6.04 (read only) SAS Transport (*.STX; *.TPT; *.XPT) SAS Value Labels SAS Version 7¨C9 SPSS Version 17 (*.SAV) SPSS Datafiles (Windows and Unix) (*.SAV) SPSS Portable Files (*.POR) Stata (all versions, including 11) (*.DTA) Statistica Versions 7¨C8 (Windows only) (*.STA) SYSTAT (Windows and Mac) (*.SY?) Triple-S Survey Interchange Format (*.xml; *.sss)
HTML Table (Output) (*.HTM*) SPSS Program + ASCII Data (Output) (*.SPS) Stata Program + ASCII Data (Output) (*.DO)
Acknowledgements
The codes to run Stat/Transfer st command are traced back to Roger Newson's stcmd, and the codes to get directory information are traced back to Morten Andersen's dirlist.
For problems and suggestions
Author: Liu wei, The School of Sociology and Population Studies, Renmin University of China. Address: Zhongguancun Street No. 59, Haidian District, ZIP Code: 100872. E-mail: rucwz-stata@yahoo.cn
Also see
Other Commands I have written:
curvefit (if installed) ssc install curvefit (to install) deci (if installed) ssc install deci (to install) fdta (if installed) ssc install fdta (to install) elife (if installed) ssc install elife (to install) freplace (if installed) ssc install freplace (to install) ftree (if installed) ssc install ftree (to install) fren (if installed) ssc install fren (to install)