Announcement

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

  • Using a global string macro in putdocx

    Hi,

    Is there way to generate a global or local macro equal to a string value like "Malawi" with the name country that could be used to replace a text value in subsequent putdocx commands? We are creating multiple sampling plans using stata and would like to do this with putdocx.

    For example,

    global country="Malawi"

    putdocx begin, header(country plan) font(arial, 11)
    putdocx paragraph, style(Title)
    putdocx text ("Country Plan for ")
    putdocx text (`country')
    putdocx save "Country plan", replace
    putdocx clear

    This would then allow the user to just replace the country name once in the putdocx file instead of multiple times each time the country changes.

    Thanks!


  • #2
    The code you show mixes a global macro definition and a local macro reference.
    Code:
    . local country "Malawi"
    
    . display "`country'"
    Malawi
    
    . 
    . global country "Sao Tome"
    
    . display "$country"
    Sao Tome
    
    .
    In the Stata User's Guide PDF included in your Stata installation and accessible from Stata's Help menu, reviewing section 18.3 will strengthen your understanding of how to work with Stata local and global macros.

    Comment


    • #3
      Thanks so much for clarifying that William. This fixed my problem perfectly!

      Comment

      Working...
      X