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]

Re: st: editing of a variable content in stata

From   "Michael N. Mitchell" <[email protected]>
To   [email protected]
Subject   Re: st: editing of a variable content in stata
Date   Fri, 28 Jan 2011 11:30:18 -0800


  I would give this a try...

generate firm1 = real(substr(firm,3,3))

The -substr()- function extracts the substring starting with the third digit, and extracting three digits, converting "IF789O" to "789", and then the -real()- function converts it into a number.

I hope that helps,

Michael N. Mitchell
Data Management Using Stata      -
A Visual Guide to Stata Graphics -
Stata tidbit of the week         -

On 2011-01-28 11.22 AM, [email protected] wrote:

I have a variable that is a code identifier for firms. it contains letters and
numbers. I would like to remove the first two digits  (these are letters) and
the last one from each firm identifier. Is this possible in stata?


Firm   Code

irm1   If7890

Firm2 Fr5671

Firm3 er4560

I would like to have at the end:
Firm   Code

Firm1  789

Firm2  567

Firm3  456

*   For searches and help try:
*   For searches and help try:

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