Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: treatment of "$" in graphics text


From   Philip Ryan <philip.ryan@adelaide.edu.au>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: treatment of "$" in graphics text
Date   Sat, 22 May 2004 12:16:19 +0930

Thanks Nick.

Having tried quite a few tricks I am, as you might say, fresh out of sausages.
Only brand "smcl" appears tasty enough to bribe the dogs.

Note (and as documented in the User's Guide, p207) that if the first character 
after the "$" is a numeral, Stata is smart enough to interpret this as 
currency, not as a global macro, and this is true for -display- or in the 
context of specifying text in a graphic. But if you want to specify the *type* 
of dollars by inserting a country's abbreviation between the "$" and the 
amount, eg $US1000 or $A2000, then the smcl code is the way to go for graph 
titles etc.

Phil


Quoting Nick Cox <n.j.cox@durham.ac.uk>:

> Here's my story, which just expands one step on what you know: 
> 
> With the -display- there are just two levels we need to think about: 
> 
> 1. Stata interprets what we type. Among other things, global 
> macros are substituted by their contents. 
> 
> 2. The -display- code tries to do what it's told. 
> 
> With 
> 
> display "price in $US"
> 
> Stata's inclination is to treat $US as a global macro, 
> which usually doesn't exist, so it's substituted by 
> a blank string. That we can fight in the two ways
> you mention, and both work. 
> 
> With the -scatter- you are seeing the consequences 
> of using an ado file which calls other ados. It's 
> a Stata principle that behaviour should be the 
> same whether something is done by part of
> the executable or an ado or a do file, but that's 
> not always possible, given other firm rules. 
> 
> With -scatter- 
> 
> scatter price weight, ytitle("price in \$US")
> 
> there are more than two levels we need to think about: 
> 
> 1. Stata interprets what we type. "\$" gets
> mapped to "$". So far, so good. 
> 
> 2. The -scatter- code tries to do what it's told. 
> 
> 3. But -scatter- is an .ado and code inside 
> that, in this case, there is a call 
> 
> graph twoway scatter price weight, ytitle("price in $US") 
> 
> which will fail to do what you for the same reason 
> as before. So, in order to get past the guard dogs, 
> Agent Ryan, you need a sausage for every dog. Whether there 
> is a clever way of nesting \$ I don't know, but I 
> doubt it, and in any case that would be an impractical 
> strategy, as you would have to know _exactly_ how many sausages 
> were needed, or more prosaically how many times your code would 
> get interpreted: with the new graphics' deeply nested
> structure, not just of ados but also of class-based
> stuff, goodness knows what the answer is. 
> 
> Incidentally, this didn't happen with the old graphics
> as what you typed would get interpreted precisely once. 
> 
> Nick 
> n.j.cox@durham.ac.uk 
> 
> > -----Original Message-----
> > From: owner-statalist@hsphsun2.harvard.edu
> > [mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of Philip Ryan
> > Sent: 21 May 2004 07:37
> > To: statalist@hsphsun2.harvard.edu
> > Subject: st: treatment of "$" in graphics text
> > 
> > 
> > Page 207 of the Users Guide [U21.3.9] instructs us on how to 
> > deal with the 
> > "$" character if we wish to display a dollar sign and _not_ 
> > consider it the 
> > marker for global macro expansion.  We can either use the "\" 
> > character  or 
> > some smcl code: {c S|} immediately prior to the "$".  These 
> > devices work 
> > for -display-.  But only the second, the smcl code, appears 
> > to work in text 
> > placed on a graphic, eg using  -title()-  -ytitle()-  -label()- etc.
> > 

-- 
Philip Ryan
Associate Professor
Department of Public Health

Associate Dean (IT)
Faculty of Health Sciences

Head, Data Management and Analysis Centre
Department of Public Health and Department of General Practice

University of Adelaide
5005 South Australia
AUSTRALIA
CRICOS Provider Number 00123M
----------------------------------------------------------- 
This email message is intended only for the addressee(s) 
and contains information that may be confidential and/or 
copyright.  If you are not the intended recipient please 
notify the sender by reply email and immediately delete 
this email. Use, disclosure or reproduction of this email 
by anyone other than the intended recipient(s) is strictly 
prohibited. No representation is made that this email or 
any attachments are free of viruses. Virus scanning is 
recommended and is the responsibility of the recipient.
*
*   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