Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: How to show variable label in a graph title


From   "Song, Lin" <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   RE: st: How to show variable label in a graph title
Date   Thu, 24 Oct 2013 19:02:20 +0000

Hi Nick,

I think I figured out the problem from your email.  In my ado program, I used tabout to generate a new dataset, and in the process, the variable label is not transferred over.  I will try to figure out a way to make it happen.

Thanks.

Lin

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
Sent: Thursday, October 24, 2013 11:19 AM
To: [email protected]
Subject: Re: st: How to show variable label in a graph title

OK.

Quotation marks within the variable label might be one problem.

But I am guessing wildly.

It's still true that you are showing us program fragments, using datasets we can't check, and yet expecting remote debugging from us.

I suspect we're going to need more code and testable examples to have a (much) better chance of helping you.
Nick
[email protected]


On 24 October 2013 19:03, Song, Lin <[email protected]> wrote:
> Hi Nick,
>
> I actually copied Sergiy's commands and double checked the quotes.  Now I'm copying them back.
>
>
> local mytitle "`: variable label `1''"
> display `"label of `1' is `mytitle'"'
>
> So this does not seem to be due to unbalanced quotes.
>
> Thanks.
>
> Lin
>
> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of Nick Cox
> Sent: Thursday, October 24, 2013 10:57 AM
> To: [email protected]
> Subject: Re: st: How to show variable label in a graph title
>
> At a rough guess, your quotation marks weren't balanced, i.e. you didn't copy Sergiy's code exactly.
>
> The check is that quotes match in pairs just as do parentheses, 
> brackets and braces in elementary algebra, namely
>
> ` '
> or
>
> " "
>
> or
>
> `" "'
>
>
>
> Nick
> [email protected]
>
>
> On 24 October 2013 18:41, Song, Lin <[email protected]> wrote:
>> Hi Sergiy,
>>
>> I tried your codes.  At the display line, I got an error message:
>>
>> label of obese is
>> too few quotes
>> r(132);
>>
>> Here "obese" is my `1' variable.  I double checked the quotes (" and `) and they are balanced on both sides in both command lines.  Why does it say "too few quotes"?
>>
>> Thanks.
>>
>> Lin
>>
>>
>>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of Sergiy 
>> Radyakin
>> Sent: Thursday, October 24, 2013 9:59 AM
>> To: [email protected]
>> Subject: Re: st: How to show variable label in a graph title
>>
>> Lin, try this:
>>
>> local mytitle "`: variable label `1''"
>> display `"label of `1' is `mytitle'"'
>> twoway (bar percent demoseq, color(green)) (rcap upper_ci lower_ci 
>> demoseq), title(`"`mytitle"')
>>
>> Does it work? and do you see the title displayed?
>>
>> Best, Sergiy Radyakin
>>
>>
>> On Thu, Oct 24, 2013 at 12:45 PM, Song, Lin <[email protected]> wrote:
>>> Hi Nick,
>>>
>>> I tried your code:
>>>
>>> title("`: var label `1''")
>>>
>>> However, it still does not work.
>>>
>>> If I only have title("`1'"), it would show the variable name.  I 
>>> also tried to add span,
>>>
>>> title("`: var label `1''", span)
>>>
>>> but this still does not work.  Nothing shows up for the title.  For the variable I tried, the variable name has 5 letters and the variable label has 15.  So it does not seem to be due to the length of the variable label.
>>>
>>> Perhaps this is because the graph command is within a program for a dialog program.
>>>
>>> In the dialog program I have:
>>>
>>>
>>> if main.rb_2l {
>>>         put "rpt2_chi "
>>>         varlist main.var_1
>>>         put " "
>>>         varlist main.var_3
>>>         }
>>>
>>> Here, main.var_3 is the the `1' variable.
>>>
>>> Then in my "rpt2.chi" ado file, I have
>>>
>>> program define rpt2_chi
>>>         ......
>>>         ......
>>>
>>>         twoway (bar percent demoseq, color(green)) (rcap upper_ci 
>>> lower_ci demoseq), title("`: var label `1''") end
>>>
>>> Do you have any idea why this is not working?
>>>
>>> Thanks.
>>>
>>> Lin
>>>
>>>
>>> -----Original Message-----
>>> From: [email protected]
>>> [mailto:[email protected]] On Behalf Of Nick Cox
>>> Sent: Thursday, October 24, 2013 9:14 AM
>>> To: [email protected]
>>> Subject: Re: st: How to show variable label in a graph title
>>>
>>> We can't explain what you did wrong without sight of code. As the 
>>> variable here is -percent-, you could just go
>>>
>>> title("`: var label percent'")
>>>
>>> but if local macro 1 contains the variable name, this should work too:
>>>
>>> title("`: var label `1''")
>>>
>>> Some minor tricks of the trade can be seen by looking inside 
>>> -aaplot-
>>> (SSC) and -multqplot- (SJ).
>>> Nick
>>> [email protected]
>>>
>>>
>>> On 24 October 2013 17:08, Song, Lin <[email protected]> wrote:
>>>> Hi Stata experts,
>>>>
>>>> I'm generating graphs using a dialog program I created.  In the following command, the title is the variable name.  However, I would like the title to be the variable label.
>>>>
>>>> twoway (bar percent demoseq) (rcap upper_ci lower_ci demoseq),
>>>> title("`1'")  xlab(#29) ylabel(#5) ytitle("percent") legend(off)
>>>>
>>>> I tried using macro to show the variable label for `1' but could not make it work.
>>>>
>>>> Do you have a solution for this?
>>>>
>>>> Thanks a lot.
>>>>
>>>> Lin
>>>>
>>>>
>>>>
>>>> *
>>>> *   For searches and help try:
>>>> *   http://www.stata.com/help.cgi?search
>>>> *   http://www.stata.com/support/faqs/resources/statalist-faq/
>>>> *   http://www.ats.ucla.edu/stat/stata/
>>> *
>>> *   For searches and help try:
>>> *   http://www.stata.com/help.cgi?search
>>> *   http://www.stata.com/support/faqs/resources/statalist-faq/
>>> *   http://www.ats.ucla.edu/stat/stata/
>>>
>>>
>>>
>>> *
>>> *   For searches and help try:
>>> *   http://www.stata.com/help.cgi?search
>>> *   http://www.stata.com/support/faqs/resources/statalist-faq/
>>> *   http://www.ats.ucla.edu/stat/stata/
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/faqs/resources/statalist-faq/
>> *   http://www.ats.ucla.edu/stat/stata/
>>
>>
>>
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/faqs/resources/statalist-faq/
>> *   http://www.ats.ucla.edu/stat/stata/
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
>
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index