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]

From |
Sergiy Radyakin <serjradyakin@gmail.com> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: How to show variable label in a graph title |

Date |
Thu, 24 Oct 2013 16:24:03 -0400 |

Lin, absence of a label should not cause an error message regarding unbalanced quotes. It should display exactly the following line: label of obese is But not the error message. So that is confusing. I was thinking exactly about the unbalanced quotes, or even some non-printable characters in the label (e.g. if produced by a data converter). If display command does not show the label - the graph command will not show it either. So troubleshoot the display command first. Try assigning your desired label immediately before you pick it up. Then move backwards in your code towards the original assignment, and see whether it is lost or transformed somewhere in the way. Another strategy would be to try a different dataset. After all, if you've created a dialog program for that command, there must be a few suitable datasets available, so just try and see if other variable labels get displayed. Once you find the one that does, see how is it different from the one that does not work (shorter, longer, contains commas, contains spaces, contains columns, quotes, etc). If you are using any command that is distorting the labels (like collapse) the solution is to back up the labels before you call the command, then reapply them immediately after. This is easily done with a loop and a bunch of locals. Hope this helps, Sergiy Radyakin On Thu, Oct 24, 2013 at 3:02 PM, Song, Lin <Lin.Song@kingcounty.gov> wrote: > 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: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox > Sent: Thursday, October 24, 2013 11:19 AM > To: statalist@hsphsun2.harvard.edu > 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 > njcoxstata@gmail.com > > > On 24 October 2013 19:03, Song, Lin <Lin.Song@kingcounty.gov> 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: owner-statalist@hsphsun2.harvard.edu >> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox >> Sent: Thursday, October 24, 2013 10:57 AM >> To: statalist@hsphsun2.harvard.edu >> 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 >> njcoxstata@gmail.com >> >> >> On 24 October 2013 18:41, Song, Lin <Lin.Song@kingcounty.gov> 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: owner-statalist@hsphsun2.harvard.edu >>> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Sergiy >>> Radyakin >>> Sent: Thursday, October 24, 2013 9:59 AM >>> To: statalist@hsphsun2.harvard.edu >>> 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 <Lin.Song@kingcounty.gov> 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: owner-statalist@hsphsun2.harvard.edu >>>> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox >>>> Sent: Thursday, October 24, 2013 9:14 AM >>>> To: statalist@hsphsun2.harvard.edu >>>> 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 >>>> njcoxstata@gmail.com >>>> >>>> >>>> On 24 October 2013 17:08, Song, Lin <Lin.Song@kingcounty.gov> 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/ * * 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/

**References**:**st: How to show variable label in a graph title***From:*"Song, Lin" <Lin.Song@kingcounty.gov>

**Re: st: How to show variable label in a graph title***From:*Nick Cox <njcoxstata@gmail.com>

**RE: st: How to show variable label in a graph title***From:*"Song, Lin" <Lin.Song@kingcounty.gov>

**Re: st: How to show variable label in a graph title***From:*Sergiy Radyakin <serjradyakin@gmail.com>

**RE: st: How to show variable label in a graph title***From:*"Song, Lin" <Lin.Song@kingcounty.gov>

**Re: st: How to show variable label in a graph title***From:*Nick Cox <njcoxstata@gmail.com>

**RE: st: How to show variable label in a graph title***From:*"Song, Lin" <Lin.Song@kingcounty.gov>

**Re: st: How to show variable label in a graph title***From:*Nick Cox <njcoxstata@gmail.com>

**RE: st: How to show variable label in a graph title***From:*"Song, Lin" <Lin.Song@kingcounty.gov>

- Prev by Date:
**Re: st: How to get rid of outliers** - Next by Date:
**Re: st: How to get rid of outliers** - Previous by thread:
**RE: st: How to show variable label in a graph title** - Next by thread:
**Re: st: How to show variable label in a graph title** - Index(es):