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

Re: st: Importing data into Stata


From   Neil Shephard <[email protected]>
To   [email protected]
Subject   Re: st: Importing data into Stata
Date   Fri, 16 Dec 2005 12:01:48 +0000

On 12/16/05, b. water <[email protected]> wrote:
> Stata 8.2 Window XP Pro SP2.
>
> . substr(v1,-6,.)
> unrecognized command:  substr
> r(199);
>
> . substr("v1",-6,.)
> unrecognized command:  substr
> r(199);
>
> . substr("abcdef",2,3)
> unrecognized command:  substr
> r(199);
>
> Any explanation for the error messages? The last example was taken straight
> from the manual [R] functions substr(s,n1,n2).
>

You need to generate a new variable, or place something into a macro.

Try...

. gen new_var = substr(v1, -6, .)

. list v1 new_var

or

. local test = substr("abcdef", 2, 3)
. di "`test'"

HTH's

Neil
--
"The surest way to make a monkey of a man is to quote him."
 - Robert Benchley

*
*   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