Statalist The Stata Listserver


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

Re: st: Problem with macro: -twoway scatter- type mismatch


From   "Ben Jann" <[email protected]>
To   [email protected]
Subject   Re: st: Problem with macro: -twoway scatter- type mismatch
Date   Mon, 20 Nov 2006 23:31:22 +0100

The quotes in

. twoway `"`scatter'"'

cause the whole macro be a single token. That is, the command expands to

. twoway `"(scatter mpg weight if make=="VW Diesel", connect(l))
(scatter mpg weight if make=="AMC Pacer", connect(l))"'

which does not make much sense - and, in addition, breaks twoway's code.
ben

On 11/20/06, Friedrich Huebler <[email protected]> wrote:
I use Stata 8.2 and built up a long macro in a loop. The macro is not
accepted by the -twoway- command and instead I get a "type mismatch
r(109);" error message. The problem can be reproduced with the auto
dataset.

. sysuse auto
. local scatter "(scatter mpg weight if make=="VW Diesel",
connect(l)) (scatter mpg weight if make=="AMC Pacer", connect(l))"
. twoway `"`scatter'"'
type mismatch
r(109);

It is possible to display the contents of the macro.

. di `"`scatter'"'
(scatter mpg weight if make=="VW Diesel", connect(l)) (scatter mpg
weight if make=="AMC Pacer", connect(l))

It is also possible to draw the graph by typing the complete -twoway-
command.

. twoway (scatter mpg weight if make=="VW Diesel", connect(l))
(scatter mpg weight if make=="AMC Pacer", connect(l))

Why does the macro not work with -twoway-? Can the problem be solved
by adding more quotes somewhere?

Friedrich



____________________________________________________________________________________
Sponsored Link

Mortgage rates near 39yr lows.
$420k for $1,399/mo. Calculate new payment!
www.LowerMyBills.com/lre
*
*   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