Announcement

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

  • Calling a program whose name is a local

    Hi all,

    My question is quite straightforward I guess but I did not find any answer on the web.

    Let's say I create a program:

    Code:
    capture program drop myprogram
    program define myprogram
        *do my things here*
    end
    Then, I can simply call it subsequently by typing
    Code:
    myprogram
    and it works fine. My question is: is it possible to do something like this below and get the program work?:
    Code:
    local myprogramname = myprogram
    `myprogramname'
    Thanks in advance for your help.

    Best,

    Michele

  • #2
    Code:
    capture program drop myprogram
    program define myprogram
        sysuse auto,clear
    end
    
    local myprogramname "myprogram"
    `myprogramname'
    Because your asking the local to be a string of text, not the name of a variable.

    Comment


    • #3
      Thanks a lot Jorrit. It worked indeed.

      Best,

      Michele

      Comment

      Working...
      X