Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: From: "Adolf Mkenda" <[email protected]>

From   Antoine Terracol <[email protected]>
To   [email protected]
Subject   Re: st: From: "Adolf Mkenda" <[email protected]>
Date   Tue, 19 Jul 2005 18:39:38 +0200

> Hi,
> I am trying to isolate some digits from a variable to form a new variable.
> For example, I have a variable with 13 digits (e.g. 5101232120011) and I
> want to extract the 6th digit (in this case 3) and make it a separate
> variable. The original variable always has 13 digits in it. I wonder
> whether I can use Stata to do this. I will appreciate suggestions.
> Adolf Mkenda
> Dar es Salaam.

Check the -substr()- function :

  From the help file (functions/string functions) :

substr(s,n1,n2) returns the substring of s starting at n1 for a length
of n2.  If n1<0, the starting position is interpreted as distance from
the end of the string. If n2 is missing (.), the remaining portion of
the string is returned.

you might have to -tostring- the -destring- the variables.


*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index