Stata: Creating graphs in loop with changing titles, longitudinal dataset -


I have a longitudinal dataset in the state, and each group has different tsline creating a variable . So, say that I'm running from 1980 to 2010 and categories 1, 2, ..., 17; I want to create a separate tsline article, which wants to conspirate the respective values ​​of variable X from 1980 to 2010 and use the Category label as a title.

I have written that a short loop tsline article , but I do not know how to add the correct title should be labeled the value of the define variable. That is, if I plot for id == 1 , then I should label this title as id == 1 , if this is possible, then ideally In, I would like to store a specific value label as local for each `i ' in the loop. In this way, I can also use it as a part of the filename, for example export the graph.

My code:

  date of tsset ID, daily fall I = 1/17 {tsline X if ID == `i ', title (??)} < / Code> 

use extended macro functions Here's an example Is:

  sysuse auto forvalues ​​i = 0/1 {local T: = 'I', title ("` t ""}}  

original variable foreign is the name of the label.> You can use the label list to list the names and contents of all the value labels. Can do

Line Local T: Label retrieves the label for the original `i ' Value in macro i , and it's macro t then you can use the macro t .

See help labels , help macros And help extended_fcn .


Comments