Announcement

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

  • Retrieve local for the value label of a specific value in a loop

    Hi all,

    I am creating many time-series graphs in a nested loop through various outcome variables and 100 values of an encoded variable. The skeleton structure is:

    foreach var of varlist{
    forval 1(1)100{
    twoway (line `var' time if group==1 and firm_size==`i') ///
    twoway (line `var' time if group==2 and firm_size==`i') ///
    ....
    twoway (line `var' time if group==N and firm_size==`i')

    graph export
    }
    }

    Anyway, I can label the y axis using the variable label from `var' using `:variable label `var''. My question is, can I title the graph in a similar manner such that the title is the value label associated with the firm_size variable at value i? So if the encoded variable firm_size takes the label "Below 10 employees" for i==1, the graph title is "Below 10 employees".

    Thank you for your help, I've been googling this for a while, but couldn't word it correctly to find the syntax I was looking for.

  • #2
    Sorry for the small typo, the forval line is of course forval i=1(1)100

    Comment


    • #3
      Code:
      line `var' time if group==1  &  firm_size==`i', title("`: label (firm_size) `i''")
      For where this is in the documentation, start at

      Code:
      help macro
      and know that this is a macro function.
      Last edited by Nick Cox; 02 Feb 2023, 09:31.

      Comment


      • #4
        Thank you for your help and clarification on it being a macro function!

        Comment

        Working...
        X