Statalist


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

RE: st: RE: Compound quotes problem


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: Compound quotes problem
Date   Wed, 9 Apr 2008 22:16:16 +0100

Sorry, I meant that you need c.d. quotes for the -display-. 
-scatter- is naturally happy with " " so long as they match. 

Nick 
n.j.cox@durham.ac.uk 

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Friedrich
Huebler
Sent: 09 April 2008 22:10
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: RE: Compound quotes problem

It works indeed. Thank you, Nick. However, the -graph- command only
works with single quotes.

. graph twoway `"`scatter'"'
scatter         ( is not a twoway plot type
r(198);

. graph twoway "`scatter'"
scatter         ( is not a twoway plot type
r(198);

. graph twoway `scatter'
[graph is drawn]

Friedrich

On Wed, Apr 9, 2008 at 4:52 PM, Nick Cox <n.j.cox@durham.ac.uk> wrote:
> This works. I wouldn't rule out other solutions.
>
>  sysuse auto, clear
>  tostring rep78, replace
>  local scatter ""
>  levels rep78, local(rep78)
>  foreach r of local rep78 {
>  local scatter `scatter' (scatter mpg weight if rep78=="`r'",
>  msize(large))
>  }
>  di `"`scatter'"'
>
>  Note that once you come out of the loop, your local includes " ", so
you
>  do need
>  c.d. quotes then. But I don't have a good explanation for why they
are
>  not essential
>  within the loop. Perhaps the parser can see that the " " are embedded
>  within the parens.
>  Not sure.
>
>  Nick
>  n.j.cox@durham.ac.uk
>
>  Friedrich Huebler
>
>  I am trying to build up a -scatter- command with a -foreach- loop. I
>  need additional quotes but do not know where to place them. The
>  problem can be reproduced with the auto data.
>
>  . sysuse auto, clear
>  . tostring rep78, replace
>  . local scatter ""
>  . levels rep78, local(rep78)
>  . foreach r of local rep78 {
>   local scatter `"`scatter' (scatter mpg weight if rep78=="`r'",
>  msize(large))"'
>   }
>  . di "`scatter'"
>   (scatter mpg weight if rep78==Unknown function .", msize()
>  r(133);
>
>  As the error message shows, I need additional quotes somewhere. How
do
>  I have to edit the definition of the macro "scatter"? In the end, the
>  macro should contain the following string, so that I can draw a graph
>  with the command -graph twoway "`scatter'"-.
>
>  (scatter mpg weight if rep78==".", msize(large)) (scatter mpg weight
>  if rep78=="1", msize(large)) (scatter mpg weight if rep78=="2",
>  msize(large)) (scatter mpg weight if rep78=="3", msize(large))
>  (scatter mpg weight if rep78=="4", msize(large)) (scatter mpg weight
>  if rep78=="5", msize(large))
*

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index