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
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: How to show variable label in a graph title
Date
Thu, 24 Oct 2013 18:24:32 +0100
You did say that you had written a dialog program, but I did not
register the importance of "dialog". I have never written dialog
programs, so cannot advise.
I know more about ado-file programming, but your last question defeats
me. You say, in effect, given a block of code that I represent by
dots, why is the next line not working? My only answer is that it
depends on how the local macro 1 is defined within all those dots.
Nick
[email protected]
On 24 October 2013 17:45, 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/