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

st: Re: Doubt about Index


From   "Scott Merryman" <[email protected]>
To   <[email protected]>
Subject   st: Re: Doubt about Index
Date   Fri, 10 Jan 2003 14:01:07 -0600

You need to specify that rg1 is a string variable (unless you have Stata 8).

gen str2 rg1=substr( rg, 1, 2)
     ^^^^

Scott

----- Original Message -----
From: "Rodrigo Brice�o" <[email protected]>
To: "Statalist (E-mail)" <[email protected]>
Sent: Friday, January 10, 2003 1:44 PM
Subject: st: Doubt about Index


> Hello friends of the list. I have a variable called rg which contains a
> large amount of numbers that represent certain income categories:
>
>     1.       01.01.01
>     2.       01.02.01
>     3.       01.02.04
>     4.    01.01.02.01
>  and so on.  I wan to extract the first two numbers in order to construct a
> new variable that tells me the main categories of income, so I will have 01,
> 02, 03 and 04. My variable is a string, so I think that I can use the substr
> function (gen rg1=substr( rg, 1,2)), but I'm getting some error 109 that
> talks about the inconsistency using numbers as strings. How can I solve
> this?
>
> Thanks for your time.
>
> Rodrigo
>
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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