Announcement

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

  • #16
    The following is not advice on how to do anything, just exploration of possibilities:
    Code:
    tempfile escaped
    filefilter asis.do "`escaped'" ,  from(\096d) to(\092d\096d) 
    include "`escaped'"
    Code:
    . type asis.do
    
    local s1 nationality_`n'!="US" & nationality_`n'!="Puerto Rico" & nationality_`n'!=""
    
    . mac dir _s1
    
    _s1:            nationality_`n'!="US" & nationality_`n'!="Puerto Rico" & nationality_`n'!=""

    Comment


    • #17
      It's hard for me to distinguish

      1. I have never needed to do this.

      2. I have never wanted to do this.

      Not wanting to seem dogmatic, or worse, but all the mentions I can recall are either someone saying you can do it and then producing contorted examples that weren't convincing -- or someone asking how to do it and struggling mightily.

      In essence, what would convince me is someone rewriting some of my code with this device and showing that it was improved thereby.

      There are plenty of languages in which it is considered good style to define a batch of constants both early in the code and together, sometimes in so-called header files. Clearly in programming you need to define something before you can use it, but in Stata practice defining locals just as you need them has a different kind of clarity.

      Nothing stops you documenting such definitions through a block of comments early in your code or in other text if clarity of documentation or ease of reading code is a criterion.

      All that said, I want to echo a hint from Bjarte Aagnes just now. This is surely where include is intended to help. Further, don't neglect characteristics as a way of defining metadata or important constants.

      Comment

      Working...
      X