Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Variable label on axis

    Hi,

    I'm constructing graphs in a loop and want to set the ytitle to the variable label not the variable name. I also want to change the size of the letters. So, right now I use
    ytitle("`var2'", size(medlarge)) in the loop over all var2, but I want to use "label of var2" instead. How can I do this?

    Thanks!

  • #2
    See

    Code:
    help macro
    and follow your nose.

    Code:
    ytitle(`"`: var label `var2''"')
    A more paranoid approach uses a variable name as back up if a variable label is not defined

    Code:
    local yttl : var label `var2'
    if `"`yttl'"' == "" local yttl "`var2'"
    ... ytitle(`"`yttl'"')
    The compound double quotes are to accommodate possible " " within the variable label.


    Comment


    • #3
      Thank you very much!

      Now, I have a similar problem: If the var2 is a list of countries with lowercase letters, e.g. germany algeria etc. However, I want the ytitle to be the uppercase country name, e.g. Germany Algeria etc. Is there a way to make that happen in the ytitle command?

      Comment


      • #4
        There are functions upper() and indeed lower(), but I think you mean and need proper():

        Code:
        . di proper("germany")
        Germany

        Comment

        Working...
        X