Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: help! Strange error in Stata


From   "Alan Neustadtl" <[email protected]>
To   [email protected]
Subject   Re: st: help! Strange error in Stata
Date   Wed, 2 Jul 2008 13:08:08 -0400

The problem is in your closing quotes for your local macro variables.
I adjusted your code to run with the auto dataset as follows:

sysuse auto, clear
sum rep78
local minyear = r(min)
local maxyear = r(max)
local yrdiff = `maxyear' - `minyear' // T-1
di `yrdiff'


Before I corrected the quotes and using your copied code I could
replicate your error in Stata10/SE for windows.

Best,
Alan





On Wed, Jul 2, 2008 at 12:42 PM, Kyle K. Hood <[email protected]> wrote:
> This code (within a do-file)
>
> . sum year
> . local minyear = r(min)
> . local maxyear = r(max)
> . local yrdiff = `maxyear' - `minyear' // T-1
>
> Generates the following result (and error):
>
> Variable | Obs Mean Std. Dev. Min Max
> -------------+--------------------------------------------------------
> year | 2244 1979.5 12.70126 1958 2001
> `maxyear' invalid name
> r(198);
>
> When I type the same code on the command line, I don't get the error --
> however, when I erase and retype the code within the do-file, I get the
> same error. I am running Stata/SE 9. I really have no idea what is going
> on. I have scrutinized for spelling, etc. The code that I sent was
> copied out of the do-file directly. I do wonder about the right single
> quote (it looks funny), but I am using Stata's do-file editor, and am
> using the single-quote-key directly to the left of the "enter" key. Can
> anyone help?
>
>
> *
> *   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