Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Re: problems with insheet and variables with "" , $ characters

From   "Ben Hoen" <>
To   <>
Subject   st: RE: Re: problems with insheet and variables with "" , $ characters
Date   Mon, 30 Jan 2012 14:59:35 -0500

Great!  The command processor is exactly what I wanted.  Thanks Joe.  

Ben Hoen
Office: 845-758-1896
Cell: 718-812-7589

-----Original Message-----
[] On Behalf Of Joseph Coveney
Sent: Friday, January 27, 2012 9:08 PM
Subject: st: Re: problems with insheet and variables with "" , $ characters

Ben Hoen wrote:

I have a large set of csv files that have roughly 60 variables (and as many
as 15,000 observations), two of variables are ad hoc descriptions (string
length 244) that users inputted and contain a whole host of characters
including: (, ), "", \, /, $, commas and many spaces.  Using insheet on the
csv file causes problems (because of the commas in these two fields I
suspect), but if I first open the file in excel and save it as a tab
delineated txt file, insheet seems to work perfectly (at least based on the
first 3 files).  

Because I have over 50 files to import I was hoping to find a way to
automate those steps.  

Any ideas for how to do this via Stata?  (I also have stat transfer)


StatTransfer's probably your better bet, and that's what I'd try first,
the lines of the following three steps.

1. If they're not already in a common directory (folder), then copy all of
.CSV files into a source directory (it can be a temporary directory created
the purpose).  

2. Write a one- or two-line script file (a simple ASCII text file having a
.STCMD extension to its name) to direct StatTransfer's "command processor"
COPY all of the .CSV files into corresponding .DTA files.  The script file
contain a line something like:

COPY <source directory>*.csv <desired target directory>*.dta

3. Exceute the .STCMD command file by double clicking on it.  It will go
all 50 .CSV files, converting them into Stata files with the same name (the
extension will of course be different).

See StatTransfer' help-file or user's manual for "command processor" for
details.  There are several settable options that you might like to set in
.STCMD script file.

Joseph Coveney

P.S. You can actually call StatTransfer from within Stata to do all of this,
the user-written -stcmd- command, immediately opening the resulting Stata
as the active dataset, but that's more of interest when working with one
conversion at at time, right when you want to work with it, instead of the
conversion approach above.

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index