help tex2colVersion 1.0.0

Title

tex2col -- Split Text into Columns

Syntax

tex2col [if] [in]
[,

columns(#)

data(string)

cname(stub)

rname(newvarname)

dpcomma

ignore("chars")]

Main
* columns(#) Number of columns
with data

* data(string) Name of the variable
that contains the data

Options
cname(stub) Column names

rname(newvarname) Row name

dpcomma Convert data with commas as decimals to period-decimal format

ignore("chars") Remove specified non-numeric characters

* Required option

Description

tex2col is aimed to split the contents of one Stata cell into
different columns,
and is particularly useful for extracting data from a PDF file and
manage it in an easy way. Use this command to convert the selected
data into a table, splitting the text into different columns.

tex2col functioning rests on two basic principles:

o First, the data variable should not have intermediate
subtitles. If that's the case, please use the command
twice, one with the first part and then with the other.

o Second, the data variable should not be in one single line
but in different lines; the number of lines
depends on the number of observations.

While the command has been set with the dot as decimal unit(default), the comma decimal unit
may be included in the options. In addition, several characters may be added to ignore in the number conversion.

Data format

tex2col requires that the information within the data variable
be separated with spaces like the example below.

The following table shows an example of the
usefulness of the tex2col command. The first column
refers to the data variable where the original information is
stored. The second column is what the command calls rname indicating
the name of the units under analysis (e.g. countries, states, counties).
Finally, the last two colums refer to cname and thus to the information
extracted from the original data variable.

DATA ROW COL_1 COL_2

Chaco Seco 16.2 24.3 Chaco Seco 16.2 24.3
Valles del Sur 12.2 18.1 Valles del Sur 12.2 18.1

Options description

Main

columns(#) Number of columns for which the data will be splited.

data(string) Name of the variable that contains the information.

Options

cname(stub) specifies column stub names e.g. if cname is col,
the variable names of the columns will then be col1, col2 and so on
(up to the number of columns specified in the columns option).
The default is col_.

rname(newvarname) specifies row name. The default rowname is row.

dpcomma convert data with commas as decimals to
period-decimal format.

ignore ("chars") remove specified non-numeric characters

Examples

Example I

. clear
. input str60 (data)
. "Chaco Húmedo 16,6 25,1 21,5 881,5 58 73 66"
. "Chaco Seco 16,2 24,3 21,3 736,1 60 79 71"
. "Valles Centrales 14,7 18,3 16,9 721,4 50 74 62"
. "Valles del Sur 12,2 18,1 16 351,3 40 70 53"
. end
. tex2col, data(data) col(7)
. list

Example II

. clear
. input str60 (data)
. "Chaco Húmedo 16,6 25,1 21,5 881,5 58 73 66"
. "Chaco Seco 16,2 24,3 21,3 736,1 60 79 71"
. "Valles Centrales 14,7 18,3 16,9 721,4 50 74 62"
. "Valles del Sur 12,2 18,1 16 351,3 40 70 53"
. end
. tex2col, data(data) col(7) dpcomma
. list

Example III

. clear
. input str60 (data)
. "Argentina 2011 18.7%"
. "Bolivia 2011 0.4%"
. "Brasil 2011 3.6%"
. "Chile 2011 1.7%"
. "Colombia 2011 5.2%"
. "Costa Rica 2010 8.0%"
. "Ecuador 2011 3.1%"
. "El Salvador 2010 0.3%"
. "Honduras 2011 3.0%"
. "México 2010 3.1%"
. "Panamá 2011 0.6%"
. "Paraguay 2010 0.9%"
. "Perú 2011 24.1%"
. "Uruguay 2011 4.3%"
. "Venezuela 2011 10.3%"
. end
. tex2col, data(data) col(2) ignore(%)
. list

Author

Santiago Garriga

Facultad de Ciencias Económicas (UNLP - Argentina)

LCSPP - World Bank

garrigasantiago@gmail.com

Also see

egen, string functions, destring