> Dear Stata users
>
> Using
>
> . do "... \square.do"
>
> . program define square
> 1. version 7.0
> 2. gettoken n 0 : 0, parse(" ,")
> 3. local nsquared1=`n'^2
> 4. local nsquared2=(`n'*`n')
> 5. di "`nsquared1' `nsquared2'"
> 6. end
> .
> end of do-file
>
> I observe the following misbehaviour of the power operator "^2"
>
> . square -2
> -4 4
>
This is because the power operator takes precedence over the negation
operator. Compare:
di -2^2
di (-2)^2
So if you edit your square program accordingly, you should be fine.
Nick Winter
*
* 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/