Multiple character slips and delimiters in Stata

advertisements

I am trying to use insheet to load in a data set from a .csv file. The delimiter in the data set is, however, "," (including the quotes) rather than simply a comma , . The top three lines in the .csv file would thus look something like this:

Name","Sex","Income
John","M","45000
Jane","F","20000

It appears that insheet does not allow for multiple-character delimiters - I get an error message that states that the "delimiter() option was incorrectly specified." Is there anyway to easy insheet data from a file like this?


Solution 1.

Stata 13 has support for multi-character delimiters. The command is import delimited. See the manual here.

Solution 2.

Use filefilter before using insheet. For example:

filefilter "source-file" "destination-file", from("\Q,\Q") to(",") replace

This replaces your multi-character delimiter with a comma delimiter. Run help filefilter.

Solution 3.

Are you not able to do a find/replace with your favorite text editor before importing to Stata? Find "," and replace with ,, for example. Then use Stata's insheet command. A good text editor may be more flexible than pure Stata in this respect.

Solution 4 (maybe).

Have you checked infix and infile? I have no experience with these but they may be worth checking out.