Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Substr not working anymore in Stata 10
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: Substr not working anymore in Stata 10
Date
Sun, 27 Mar 2011 10:57:11 +0100
Programming languages are not like domestic appliances, which can
suddenly stop working!
All Diego is getting wrong here is that he inserted a space where one
changes his meaning.
Stata is reading his statement left to right. When it sees an isolated
-substr-, it expects this to be the name of a variable or scalar.
Clearly, Diego has no such variable or scalar, so Stata issues an
error message.
Diego expects Stata to realise that he means -substr()- with its
argument, but Stata is strong on syntax and weak on semantics.
Just zap that space!
In addition, Diego may want the numeric equivalent in which case
gen hrs_inicio= real(substr(chorainici, 1,2))
is the way to go.
Nick
On Sun, Mar 27, 2011 at 10:25 AM, Diego Canales <[email protected]> wrote:
> I was just recently looking at the thread "Splitting string variables
> without parse strings" and the command that works for this task, which is
> the same problem I have, substr, doesn't seem to be working anymore for
> Stata 10. If I type help substr, an explanation still appears, but when I
> run the following:
>
> gen hrs_inicio= substr (chorainici, 1,2)
>
> Stata gives me a: substr not found.
>
> chorainici is a 4 digit string variable, such as 1416, and I need the first
> two digits in a new variable.
>
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/