Announcement

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

  • Dollar sign in local?

    Dear Statalist,

    I would like to have a local (string) with the dollar sign in it without being evaluated. I read Nick's article on backslashes, (file:///C:/Users/wb327173/Downloads/pr0042.pdf), however it seems that they are for labeling, not for local.

    In Stata, it shows the dollar sign in the string as the output in Results window.
    . display "\$myfile"
    $myfile

    How can I do that in a local? I tried some parts here, but unable to show that dollar sign in the content of the local.
    local a `"\$myfile"'
    dis "`a'"

    local a `"\\$myfile"'
    dis "`a'"

    Many thanks,
    Minh

  • #2
    The problem is not just getting it in. It's stopping it being misinterpreted as a global.

    Code:
     
    . local foo = char(36) + "frog"
    
    . mac li
    <stuff omitted> 
    _foo:           $frog
    
    . di "`foo'"
    Or

    Code:
     
    . local bar = "\"  + char(36) + "frog"
    
    . mac li
    <stuff omitted> 
    _bar:           \$frog
    _foo:           $frog
    
    . di "`bar'"
    \
    Why do you think you need this? I would keep dollar signs separate from almost anything else.

    Comment


    • #3
      Many thanks, Nick.
      I am passing those locals to a shell, with 1 liner code, so in their languages $ is the start of the command.

      Thanks,
      Minh

      Comment


      • #4
        Getting it in may be sufficient then. Consider using char(36) if necessary.

        Comment

        Working...
        X