Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

st: RE: Data Extraction from Cells

From   "Nick Cox" <>
To   <>
Subject   st: RE: Data Extraction from Cells
Date   Mon, 12 Jul 2010 14:56:57 +0100

"cell" here appears to mean value of a string variable in an

"column" here appears to mean variable. 

Stata is not a spreadsheet! 

-substr()- is the appropriate function. See -help functions- and then
look under string functions. 

gen part1 = substr(whatever, 1, 2) 
gen part2 = substr(whatever, 3, 2)
gen part3 = substr(whatever, 5, 2) 


Samuel Finkelstein

I am currently using a dataset that
includes multiple indicators within the same cell.  For instance, if a
firm is publicly traded, was incorporated in the last five years, and
is in the utilities industry, a single cell may contain information
such as 1A3B3N, with each number/letter combination denoting one of
these characteristics (with no spaces in between the various
combinations).  Is there a way that I can extract each of the
number/letter cominations into different (newly created) columns, such
that I have one column that has 1A, one column with 3B, and one with
3N?  For my purposes, the columns can contain different
codes/identifiers.  For example, the first column could have 1A for
Company A and 2F for Company B.  I am only trying to use these codes
to identify firms with two or three specific characteristics.

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index