Announcement

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

  • Parallel list using word command - but need to extract more than one word

    Hi,

    I am not an expert in using the word command to help running parallel lists, so maybe someone can help

    I have the following global to help me adding notes to graphs:

    Code:
    global ss_model_type_graph_note " " "Leave one out measure " ///
    "Restricted sample "
    I then run a forloop that involves many steps (not shown), with the ultimate goal of creating a graph:
    Code:
    forvalues k = 1/3{
    clear
        
    local kname : word `k' of $ss_model_type
    local knote: word `k' of $ss_model_type_graph_note
    
    twoway ///
        (scatter coefficient t , mlabel("") msymbol(O) msize(small)) ///
        (rcap lower_bound upper_bound t , lcolor(black) mc(blue)), ///
        note( "`knote'", size(small)) ///
        yline(0) ylabel(, format(%12.2fc) angle(0)) ///
        xlabel(-4(1)7, format(%12.0fc)) ///
        legend(off) ///
        graph export "`kname'.pdf", replace
    }
    Ultimately k should go further than 3, so I try to add the notes in a single macro and then use the forval loop to change the graph's format accordingly.

    This is clearly not working, because each piece of ss_model_type_graph_note has multiple words.

    So for the graph in k=1 I get the correct caption - empty. For k=2, it is wrong, it only writes "Leave", for k=3 it only writes "one"

    Is there a way to change this for me to get the full sentence for each?

  • #2
    Code:
    local brands `""AMC Concord""AMC Pacer""AMC Spirit""Buick Century""Buick Electra""'
    
    tokenize `"`brands'"'
    
    display "`1'"
    display "`3'"
    display "`5'"
    Res.:

    Code:
    . display "`1'"
    AMC Concord
    
    . 
    . display "`3'"
    AMC Spirit
    
    . 
    . display "`5'"
    Buick Electra
    
    .

    Comment


    • #3
      Andrew Musau thank you, this is great!

      Comment

      Working...
      X